why the perl regular expression is not identifying the value

36 views Asked by At

I have the below data where I am trying to identify the '-0.00' value with regular expression but that seems not working , please let me know why and provide a working solution

data master;
  input val$ ;
match = prxmatch('m/^\-\d[0]\.\d[0]+/o', strip(val));
  datalines;
-0.00
-0.05
0.00
;
run;

here i am using the below regex

\- to detect -
\d[0] detect digit which is 0
\. detect a dot
\d[0]+ detect digit which is 0 and happens to be more than once

I tried using the below and it works but i dont want to use this approach

match = prxmatch('m/^-0.00/o', strip(val));

1

There are 1 answers

0
Richard On
  • \d detects any digit
  • 0 will detect 0
  • [0] will also detect 0
  • \d[0] you are asking to detect any digit followed by 0

in SAS you might be better served with val_n = INPUT(val,??best.)