Regex not correctly identifying string (Python) -


i using online regex debugger regexr (www.regexr.com), correctly identifying working , non-working regex's me part. however, stuck on 2 specific regex's regexr identifies working correctly, yet won't work in implementation. first using locate pgp keys, header , footer. regex is:

[-]{5}[a-z]{3,5}\spgp\smessage[-]{5}[^.] 

and using identify:

-----begin pgp message----- 

and

-----end pgp message----- 

my other regex won't work in actual implementation identifying uk passport numbers:

\b[0-9]{10}gb[rp][0-9]{7}[umf]{1}[0-9]{9}\b 

examples work in regexr:

7086493126gbr6510204m150224602  1234567890gbp1234567f123456712 

could offer insight why these not work?

i think problem final part of regex: [^.]

that match character not literal period. don't think intended use it, , cause regex not match beginning , end messages themselves.

just clear -- while . metacharacter, within [] it's literal character.

as gb passport ids, i'd have see string in more context, problem word boundary metacharacters.


Popular posts from this blog