DATA Step, Macro, Functions and more

Where are the regular expression functions' options documented?

Accepted Solution Solved
Reply
PROC Star
Posts: 7,366
Accepted Solution

Where are the regular expression functions' options documented?

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

 


Accepted Solutions
Solution
‎06-28-2017 06:48 PM
PROC Star
Posts: 290

Re: Where are the regular expression functions' options documented?

[ Edited ]

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


All Replies
Solution
‎06-28-2017 06:48 PM
PROC Star
Posts: 290

Re: Where are the regular expression functions' options documented?

[ Edited ]

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

PROC Star
Posts: 7,366

Re: Where are the regular expression functions' options documented?

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

 

PROC Star
Posts: 1,570

Re: Where are the regular expression functions' options documented?

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. Smiley Happy

 

PROC Star
Posts: 7,366

Re: Where are the regular expression functions' options documented?

[ Edited ]

@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

 

PROC Star
Posts: 1,570

Re: Where are the regular expression functions' options documented?

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

Frequent Contributor
Posts: 104

Re: Where are the regular expression functions' options documented?

[ Edited ]

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 Smiley Wink forum provided me with answers each time I was stuck.

________________________

- Cheers -

PROC Star
Posts: 7,366

Re: Where are the regular expression functions' options documented?

@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

 

Community Manager
Posts: 2,772

Re: Where are the regular expression functions' options documented?

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.

PROC Star
Posts: 7,366

Re: Where are the regular expression functions' options documented?

@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

Community Manager
Posts: 2,772

Re: Where are the regular expression functions' options documented?

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

PROC Star
Posts: 1,570

Re: Where are the regular expression functions' options documented?

@ChrisHemedinger This list is incomplete. 

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

SAS Employee
Posts: 5

Re: Where are the regular expression functions' options documented?

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.

PROC Star
Posts: 7,366

Re: Where are the regular expression functions' options documented?

@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

SAS Employee
Posts: 5

Re: Where are the regular expression functions' options documented?

Thanks for the clarification Art. I'll research the PRX functions and get back to you.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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