I apologize - I apparently lost track of this...
In Spark (but not in Databricks), both of these:
regexp_replace('1234567890abc', '^(?<one>\\w)(?<two>\\w)(?<three>\\w)', '$1')
regexp_replace('1234567890abc', '^(?<one>\\w)(?<two>\\w)(?<three>\\w)', '${one}')
result in:
14567890abc
In general, I've found Databricks to work at least as well as Spark but it fails to work correctly in this situation.
In Databricks, you have to use these variations (which are not standard Spark):
regexp_replace('1234567890abc', '^(?<one>\\w)(?<two>\\w)(?<three>\\w)', '\$1')
regexp_replace('1234567890abc', '^(?<one>\\w)(?<two>\\w)(?<three>\\w)', '\$\{one}')
(note that the named capture requires escaping both the $ and the { )
Upon further testing, $# and ${name} do not work in RLIKE after all (in Databricks at least - have not tested Spark). For example:
regexp_extract('aabc', '^(\\w)$1', 0)
returns "a" (not "aa") but '^(\\w)\1' works correctly.