Suppose I have a string variable Name that is formatted as Text1 (Text2) (Text3), how can I use regular expressions alone to get a new variable that takes the value Text2?
I managed by this
Code:
gen x=regexs(1) if regexm(Name,"\(+(.*)\)?") gen y=strpos(x,")")-1 gen z=substr(x,1,y)
I understand we can extract the desired string using simple string functions or even Nick's -moss- command but I am trying to use regular expressions in one step alone without steps 2 and 3 above.
Any ideas?
Thanks
Abhimanyu
0 Response to regular expression to extract a part of a string variable
Post a Comment