I get the correct matches: "PR1," , "PR12," and "PR23". The last one is in the list because it
indeed starts with "PR", has "1 to 2 digits", and ends with "zero or more non-letters" (actually zero).
Wild guess: may be you need to insert the "word end" mark after digits:
\<PR\d{1,2}\>[^a-zA-Z]*
In that case you get only "PR1," and "PR12,".
Does it help?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I've a list of strings which contain substrings like this:
ABC, XYZ,PR1,PR12,aPR1,PR23a,...
I want to find only PR1,PR12.
The pattern should be : \<PR\d{1,2}[^a-zA-Z]*
But PR23a is also in the list. Why?
thx,
Oliver
I couldn't find any problem with it.
Matching
\<PR\d{1,2}[^a-zA-Z]*
against the string
ABC, XYZ,PR1,PR12,aPR1,PR23a,...
I get the correct matches: "PR1," , "PR12," and "PR23". The last one is in the list because it
indeed starts with "PR", has "1 to 2 digits", and ends with "zero or more non-letters" (actually zero).
Wild guess: may be you need to insert the "word end" mark after digits:
\<PR\d{1,2}\>[^a-zA-Z]*
In that case you get only "PR1," and "PR12,".
Does it help?