DATA Step, Macro, Functions and more

Problem with PRXMATCH

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

Problem with PRXMATCH

I'm looking to extract IBAN numbers from some SWIFT data I have, but my PRXMATCH function doesn't seem to be working, does anyone know why?

 

An example of the text field I'm searching in would be:

LV05AIZK1234567891234  COMPANY NAME ADDRESS

 

In order to find the starting character for the match to use in a substring extract, I'm using:

PRXMATCH('/\LV\d{2}\D{4}\d{13}\s/', COLUMN)

 

This looks right to me but I keep getting a result of zero where I can see this IBAN form in the data.


Accepted Solutions
Solution
‎10-18-2017 11:15 AM
PROC Star
Posts: 399

Re: Problem with PRXMATCH

[ Edited ]

This seemes to work Smiley Happy

 

data one;
length iban $32 column $200;
column = 'One IBAN Number: LV05AIZK1234567891234 COMPANY NAME ADDRESS';
pos = PRXMATCH('/LV\d{2}\D{4}\d{13}/', COLUMN);
run;

 

I removed the first \ and the trailing \s.....

 

//Fredrik

View solution in original post


All Replies
Super User
Super User
Posts: 9,840

Re: Problem with PRXMATCH

Would not scan(string,1," ") not work?

Occasional Contributor
Posts: 16

Re: Problem with PRXMATCH

That's a much neater solution for this particular problem thanks. For instances where the IBAN can potentially be anywhere in the string, can you think what's wrong the the PRXPARSE statement? 

Super User
Super User
Posts: 9,840

Re: Problem with PRXMATCH

Well, I am not familiar with Perl so much, so will let others comment on that.  If it always starts with "LV" and length 21 which your regex seems to indicate then:

want=substr(thestring,index(thestring,"LV"),21);

So find LV in the string, and then substr out 21 characters from there.

Occasional Contributor
Posts: 16

Re: Problem with PRXMATCH

Perfect, thanks

Solution
‎10-18-2017 11:15 AM
PROC Star
Posts: 399

Re: Problem with PRXMATCH

[ Edited ]

This seemes to work Smiley Happy

 

data one;
length iban $32 column $200;
column = 'One IBAN Number: LV05AIZK1234567891234 COMPANY NAME ADDRESS';
pos = PRXMATCH('/LV\d{2}\D{4}\d{13}/', COLUMN);
run;

 

I removed the first \ and the trailing \s.....

 

//Fredrik

Occasional Contributor
Posts: 16

Re: Problem with PRXMATCH

Yes, this works now thanks

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 282 views
  • 0 likes
  • 3 in conversation