Suppose I have a sequence of strings that looks something like this:
1 10 46565 5968678 3 567 78
I would like to turn it into
F(1) F(10) F(46565) F(5968678) F(3) F(567) F(78)
Is there a regex one-liner that will accomplish that in Stata with an arbitary number of elements?
I tried:
. display ustrregexra("1 10 46565 5968678 3 567 78","([:digit:]){1,}","XXX")
XXX XXX XXX XXX XXX XXX XXX
and
. display ustrregexra("1 10 46565 5968678 3 567 78","([:digit:]){1,}","F(&)")
F(&) F(&) F(&) F(&) F(&) F(&) F(&)
and
. display ustrregexra("1 10 46565 5968678 3 567 78","[0-9]{1,}","F(&)")
F(&) F(&) F(&) F(&) F(&) F(&) F(&)
In VI, this seems to do the trick:
.s/[0-9]\{1,}/F(&)/g
Is there any equivalent of that in Stata for the unicode or vanilla regex functions? Stata's ustrregex* functions are bases on the ICU regex engine according to this comment by a StataCorp programmer.