Q:

python regular expression exclude from match string

I have 3 strings
a ="keep the your pass ABCDEFG other text"
b ="your pass: TESTVALUE other text"
c ="no pass required other text"

I want to get capital values after pass, like this
re.match(r'.*\spass:?\s([a-zA-Z]+).*',a,re.I).group(1)
re.match(r'.*\spass:?\s([a-zA-Z]+).*',b,re.I).group(1)

but I want to exclude "no pass", which is I don't want re to match to c string, how do I do that?

Solution: Thanks eyquem and ovgolovin
I will take eyquem's suggestion of re.search('no\s+pass|pass:?\s+([A-Z]+)')

A:

import re

for x in ("keep the your pass ABCDEFG other text",
          "your pass: TESTVALUE other text",
          "no pass required other text"):
    print re.search('no\s+pass|pass:?\s+([A-Z]+)',x).group(1)
A-Z]+)'

result
ABCDEFG
TESTVALUE
None

