在SAS中使用正则表达式提取子字符串 [英] extracting substring using regex in sas

查看:185
本文介绍了在SAS中使用正则表达式提取子字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的字符串:

I have a string like this:

dfjkldjfdsldfkdslfkd dfkdjd/FR018/HAHDFKDLFDAFHDKFJL/ABCD//NAME/I WANT TO EXTRACT THIS/JJJJ//NAME/blah blah blah

在此字符串中,我希望能够提取字符串 I WANT TO EXTRACT THIS .换句话说,我想提取/ABCD//NAME/之后和/JJJJ 之前的所有内容.

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?

谢谢

推荐答案

我对SAS不熟悉,但是从

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;

这篇关于在SAS中使用正则表达式提取子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆