extracting substring using regex in sas

蓝咒 提交于 2021-01-29 12:09:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!