Reputation: 3451
For a text like
1" 77568T86 34
2" 5347A1Q 456
I'd like to return strings 77568T
and 5437A
I'm guessing I want something that begins like \d{4,5}
EDIT: Thanks for all the responses. Unfortunately, nothing is working in notepad++, even though they work with online regex testers.
I think the problem is notepad++'s handling of {} because (\d[A-Z])
finds matches.
Advice?
Upvotes: 3
Views: 8173
Reputation: 168655
You got the number bit right; you just need to add a letter class to the end of your expression:
\d{4,5}[a-zA-Z]
(this allows upper or lower case; remove the a-z
if you only want upper case)
Upvotes: 1
Reputation: 270609
Yes you're on the right track. Just add a single [A-Z]
following the number group (use [A-Za-z]
if it should be case insensitive).
\d{4,5}[A-Z]
If it should be preceded by whitespace or some boundary, prepend a \b
\b\d{4,5}[A-Z]
I'm not familiar with how Notepad++ handles match capture groups, but it is likely you will want the whole thing surrounded in ()
\b(\d{4,5}[A-Z])
Upvotes: 4