BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
art297
Opal | Level 21

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
collinelliot
Barite | Level 11

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:

   Perl Artistic License Compliance

View solution in original post

16 REPLIES 16
collinelliot
Barite | Level 11

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:

   Perl Artistic License Compliance

art297
Opal | Level 21

@collinelliot: Quite possibly but, since I can't find anything in the SAS documentation, I don't know.

 

ChrisNZ
Tourmaline | Level 20

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. 🙂

 

art297
Opal | Level 21

@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

 

ChrisNZ
Tourmaline | Level 20

@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.

Oligolas
Barite | Level 11

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 -

art297
Opal | Level 21

@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

 

ChrisHemedinger
Community Manager

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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
art297
Opal | Level 21

@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

ChrisHemedinger
Community Manager

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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
ChrisNZ
Tourmaline | Level 20

@ChrisHemedinger This list is incomplete. 

Some supported expressions are missing, like \G  (not \Q as I stated above, my bad).

daharr
SAS Employee

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.

art297
Opal | Level 21

@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-expressionsource)

 

It doesn't indicate anything regarding options (e.g., /i).

 

Art, CEO, AnalystFinder.com

daharr
SAS Employee
Thanks for the clarification Art. I'll research the PRX functions and get back to you.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 16 replies
  • 2677 views
  • 3 likes
  • 6 in conversation