BookmarkSubscribeRSS Feed
car
Calcite | Level 5 car
Calcite | Level 5

Hello,
I  got  my  nice  regex

PRXMATCH("/^¬[A-Z0-9 '.,-]{8,40}¬¬[A-Z'.,-]{2,40}/",DIRETI2)

There  is one  record  where  DIRETI2  I has

¬01210 BRUXELLES¬¬BÉLGICA

It  doesn't  match because  I got an  accent...

Is there  an  elegant  way  to include accents?

Thanks,

4 REPLIES 4
FriedEgg
SAS Employee

In Perl itself I there is a metacharacter \p{L} which matches a alphabetical character in 'any' language, however, it is not available in SAS.  Your options would be to trantab the input or to add the acceptable non-ascii characters to your regular expression:

data _null_;

input DIRETI2 $80.;

rc=PRXMATCH("/^¬[A-Z0-9 '.,-]{8,40}¬¬[A-ZáéíóúÁÉÍüÓÚâêÄîôßûÂÊÎÔÛäüöÄÜÖýµäöü'.,-]{2,40}/",DIRETI2);

put direti2= rc=;

cards;

¬01210 BRUXELLES¬¬BÉLGICA

;

run;

Patrick
Opal | Level 21

Character Class Groupings is what you might be looking for: SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition

Also: Make sure to mask a '.' as else is has the meaning of a wildcard.

data test;

  DIRETI2='¬01210 BRUXELLES¬¬BÉLGICA';

  rc1=PRXMATCH("/^¬[A-Z0-9 '.,-]{8,40}¬¬[A-Z'.,-]{2,40}/",DIRETI2);

  rc2=PRXMATCH("/^¬[[:alnum:] '\.,-]{8,40}¬¬[[:alpha:]'\.,-]{2,40}/o",DIRETI2);

run;

FriedEgg
SAS Employee

This will depend on your session encoding for whether it will work or not.

Session Encoding = latin1, will work.  If you have session encoding = utf-8, it will NOT work...

car
Calcite | Level 5 car
Calcite | Level 5

I suppose  our enconding is  latin1.

PRXMATCH("/^¬[[:alnum:] '\.,-]{8,40}¬¬[[:alpha:]'\.,-]{2,40}/o",DIRETI2);

Works  fine for me.   No more issues  with accents.

Thank you!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1042 views
  • 1 like
  • 3 in conversation