I know that /i means case insensitive, but I can't find anything (other than an example of its use) in the documentation.
Can someone provide a link to the regular expression functions' options?
TIA,
Art, CEO, AnalystFinder.com
I've failed to find this myself beyond cases where modifiers are used in examples. Is there any chance that the Perl documentation applies to SAS, or at least partially?
http://perldoc.perl.org/perlre.html#Modifiers
And this from @Oligolas:
I've just found a list of not supported items:
I've failed to find this myself beyond cases where modifiers are used in examples. Is there any chance that the Perl documentation applies to SAS, or at least partially?
http://perldoc.perl.org/perlre.html#Modifiers
And this from @Oligolas:
I've just found a list of not supported items:
@collinelliot: Quite possibly but, since I can't find anything in the SAS documentation, I don't know.
SAS can use most of the Perl expressions.
There is no comprehensive documentation about what is supported that I know of, and what I found was wrong, for example stating that \G (zero-width assertion to match the previous match) was unsupported when it actually is.
That's why I added a chapter (in the second edition of the book behind the link below) detailing all the Perl regular expressions that SAS supports. 🙂
@collinelliot: Not the answer I was hoping for but, apparently, at least info I can work with! @ChrisNZ: I'll have to take a look at your book, but I was hoping that SAS had documented the functions.
@ChrisHemedinger: Chris, would you mind checking with the docmentation folks to find out why this info isn't there?
Appreciated,
Art, CEO, AnalystFinder.com
@art297 I couldn't find any suitable source. It would have saved me countless hours. This doesn't mean that such a source does not exist and I'd glad to know about it if there is one.
Hi,
In the online reference for functions and call routines SAS provides Tables of Perl Regular Expression (PRX) Metacharacters
It Seems to be very complete, including look ahead/behind behaviour.
I found it very interesting and will certainly refer to it. The table "Comments and Inline Modifiers" states that (?i) at the front of the pattern makes it case insensitive, i've used /i with brackets until now.
Nevertheless I use this page when I'm looking for ways to do things.
And last but not least this 😉 forum provided me with answers each time I was stuck.
- Cheers -
@Oligolas: Yes, that table is quite useful. However, my principal concern is about the fact that regular expression functions AREN'T even mentioned in the documentation. The rule-of-thumb that most profess is that if something isn't in the documentation IT ISN'T SUPPORTED and shouldn't be used in production code as it might not work in future versions.
Art, CEO, AnalystFinder.com
From SAS doc, check this:
Using Perl Regular Expressions in the DATA Step
Which links to this:
Table of Perl Regular Expression (PRX) Metacharacters
And in practice, I often refer to interactive tools such as Regex 101 to build/test regex expressions, which I then paste into SAS syntax.
@ChrisHemedinger: Thanks for correcting the link to you in my previous post. And, while I was already familiar with them, thanks for the links to the documentation links you listed in your post. However, unless I missed it, that documentation doesn't mention anything about the existence, meaning or use of options one can include (e.g., /i). Those are the ones I'm interested to see and know what is or isn't officially supported.
Art, CEO, AnalystFinder.com
Okay @art297, now I see your point. You're looking for doc (and verification) on options like /i (ignore case) /m (multiline) /o (perform substitutions just once), etc. For the record, I think those all work, but I also can't find them in the official doc from SAS. I think @daharr is the doc writer for this area -- maybe he can chime in with a reference.
Those getting started with SAS and regular expressions might be interested in this book:
Introduction to Regular Expressions in SAS by @Matt_Windham
Chris
@ChrisHemedinger This list is incomplete.
Some supported expressions are missing, like \G (not \Q as I stated above, my bad).
We only document these expressions in the Functions and Call Routines document.
Years ago SAS decided not to include all of the expressions, only commonly used expressions that are included in the Tables of Perl Regular Expression (PRX) Metacharacters table. We also give more information in the Using Perl Regular Expressions in the DATA Step section.
I will contact R&D and have them review the PRX table. I'll update the table with missing expressions.
Thanks for the messages.
@daharr: Thanks for responding. However, my concern IS with the Functions and Call Routines document.
It doesn't, as far as I can tell, include any indication that the functions support ANY options. e.g., the documentation for the PRXMATCH function's syntax is shown as: PRXMATCH(regular-expression-id | perl-regular-expression, source)
It doesn't indicate anything regarding options (e.g., /i).
Art, CEO, AnalystFinder.com
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.