Hi,
I ran into an issue while using regexm to search for a string with a "$" followed by capital or lower case letters (i.e. "\$[a-zA-Z]). My expression is recognized in python, but not when using regexm in Stata. I messed a round a bit and it seems like anytime "\$" is preceded or followed by other characters (I've tried numbers and 'special' characters too) Stata doesn't recognize those other characters. I understand that "" is needed to prevent Stata from looking for a global and have provided some code below that I think more clearly illustrates the issue. I've figured out a work around using python, but this was still bothering me so I thought I'd see if anyone knew what was going on. I'm using Stata 16.
Thank you,
Phoebe
I ran into an issue while using regexm to search for a string with a "$" followed by capital or lower case letters (i.e. "\$[a-zA-Z]). My expression is recognized in python, but not when using regexm in Stata. I messed a round a bit and it seems like anytime "\$" is preceded or followed by other characters (I've tried numbers and 'special' characters too) Stata doesn't recognize those other characters. I understand that "" is needed to prevent Stata from looking for a global and have provided some code below that I think more clearly illustrates the issue. I've figured out a work around using python, but this was still bothering me so I thought I'd see if anyone knew what was going on. I'm using Stata 16.
Code:
gen dollar = "$" gen check = regexm(dollar,"\$") assert check == 1 gen dollar_abc = "\$abc" gen check_abc = regexm(dollar,"\$abc") assert check_abc == 1 \\ Fails for me because check_abc has all 0's gen abc_dollar = "abc$" gen abc_check = regexm(dollar,"abc\$") assert abc_check == 1 \\ Fails for me because abc_check also has all 0's
Thank you,
Phoebe
Comment