楼主: Tigflanker
1398 8

[问答] 求教一个较小的正则问题 [推广有奖]

  • 8关注
  • 18粉丝

副教授

49%

还不是VIP/贵宾

-

威望
0
论坛币
2321 个
通用积分
9.9128
学术水平
179 点
热心指数
194 点
信用等级
167 点
经验
27443 点
帖子
622
精华
0
在线时间
851 小时
注册时间
2011-3-27
最后登录
2023-5-14

楼主
Tigflanker 发表于 2014-3-21 20:00:59 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问一下,我想匹配一个非 ‘_’ 的其他符号,应该怎么处理呢?

[[:punct:]]这是任意符号,怎么把下划线的情况剃掉呢?

谢谢 :)

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:怎么处理 UNC 下划线 pun 下划线

回帖推荐

farmman60 发表于5楼  查看完整内容

Not Prx. data have; input x $; pos=findc(x,'_ ','kad'); cards; 34jfk _e35$& %7yud_u 1a34_6|89 ; run;
Bye SAS.
若有缘,能重聚。

沙发
yongyitian 发表于 2014-3-22 10:39:08
  1. /* [^_]  match an any character except an underscore "_" */  

  2. data _null_;
  3. if _n_ = 1 then do;
  4.      pn1="/_/";        p1=prxparse(pn1);
  5.      pn2="/[^_]/";     p2=prxparse(pn2);
  6.      retain p1 p2;
  7. end;
  8. input string $10.;
  9.     position1 = prxmatch(p1, string);  
  10.     put _n_=  "P1     underscore _ is found at position " position1 " in the string: " string;
  11.     position2 = prxmatch(p2, string);  
  12.     put _n_=  "P2 non-underscore is found at position " position2 " in the string: " string;
  13. datalines;
  14. 1234_56789
  15. ____5_____
  16. ; run;
复制代码
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 谢谢~请看我的回复:)

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

藤椅
farmman60 发表于 2014-3-22 11:25:06
I am not fully sure about your second question. Because compress could be used in similar condition
like  x=compress(x,'_').

data _null_;
input x$20.
x=prxchange('s/_//',-1,x);
put x;
cards;
_dj23jk
dl&_k7j
ui%*uy
$dk(_23
;
run;




已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 谢谢,不过有点不是这个意思。。

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

板凳
Tigflanker 发表于 2014-3-24 12:42:07
yongyitian 发表于 2014-3-22 10:39
/* [^_]  match an any symbol except an underscore "_" */  

data _null_;
if _n_ = 1 then do;
     p2=prxparse("/[^_]/");
     retain p2;
end;
input string $10.;
    position2 = prxmatch(p2, string);  
    put "First position for non _ but a symbol is 7 '|' ? :" position2;
datalines;
1a34_6|89
; run;

是这样的,我想找串中的第一个非下划线的符号。

是符号,但是惟独不是下划线。
Bye SAS.
若有缘,能重聚。

报纸
farmman60 发表于 2014-3-24 19:31:48
Not Prx.

data have;
input x $;
pos=findc(x,'_ ','kad');
cards;
34jfk
_e35$&
%7yud_u
1a34_6|89
;
run;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 2 + 2 + 2 见回复。

总评分: 学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

地板
Tigflanker 发表于 2014-3-24 22:02:31
farmman60 发表于 2014-3-24 19:31
Not Prx.

data have;
谢谢!非常感谢!

9.2的函数,虽然不是想要的,不过收获很大!!
Bye SAS.
若有缘,能重聚。

7
Tigflanker 发表于 2014-3-24 22:11:08
farmman60 发表于 2014-3-24 19:31
Not Prx.

data have;
请问,在哪里可以找到kad及相关的参数?

在sas的support中也没有查到。。谢谢
Bye SAS.
若有缘,能重聚。

8
farmman60 发表于 2014-3-25 09:01:17
You could find information on findc function at:
https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002264923.htm

In addition, here is method to find punctuation position with prx.

data have;
input x$ ;
pos=findc(x,'_ ','kad');
prx_pos=prxmatch('/[^a-z0-9_]/',strip(x));
cards;
34jfk
_e35&
%7yud_u
1a34_6|89
;
run;

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 thanks a lot~~

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

9
yongyitian 发表于 2014-3-25 10:30:12
Tigflanker 发表于 2014-3-24 12:42
/* [^_]  match an any symbol except an underscore "_" */  

data _null_;
明白你要做什么了,感觉不太可能把这两件事情放在一个 prx-pattern.

Not sure whether the following is the same as your case. But you have many ways to do it with two patterns.

data _null_;
if _n_ = 1 then do;
     pn1="/[[:punct:]]/";      p1 = prxparse(pn1);
         pn2="/[_]/";               p2=prxparse(pn2);
         retain p1 p2;
end;
input string $10.;
    position1 = prxmatch(p1, string);  
    position2 = prxmatch(p2, string);  
    if position1 = position2 then
put _n_=   "the first punctuation is found     to be an _ at position: " position1 " in string: " string;
    if position1 ^= position2 then
put _n_= "the first punctuation is found not to be an _ at position: " position1 " in string: " string;
datalines;
1234__&*=_
1234*:'_?_
^~!',:"??_
_~!',:"??_
; run;   

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 明白了,谢谢:)

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 17:33