问题
I have a string like this:
dfjkldjfdsldfkdslfkd dfkdjd/FR018/HAHDFKDLFDAFHDKFJL/ABCD//NAME/I WANT TO EXTRACT THIS/JJJJ//NAME/blah blah blah
in this string, I want to be able to pull the string I WANT TO EXTRACT THIS
. In other words, I want to extract everything that follows /ABCD//NAME/
and before /JJJJ
.
how can I write this using regular expressions?
thanks
回答1:
I am not familiar with SAS, but from the documentation it seems like you can do:
re = prxparse('/\/ABCD\/\/NAME\/(.*?)\/(.*?)\/JJJJ/s');
if prxmatch(re, str) then
do;
res = prxposn(re, 1, str);
end;
来源:https://stackoverflow.com/questions/58275744/extracting-substring-using-regex-in-sas