different behavior when using re.finditer and re.match.

Posted by Shahzad on Stack Overflow See other posts from Stack Overflow or by Shahzad
Published on 2011-01-10T12:39:13Z Indexed on 2011/01/10 12:53 UTC
Read the original article Hit count: 167

Filed under:
|
|

Hi, I'm working on a regex to to collect some values from a page through some script. I'm using re.match in condition but it returns false but if i use finditer it returns true and body of condition is executed. i tested that regex in my own built tester and it's working there but not in script. here is sample script.

result = []
RE_Add0 = re.compile("\d{5}(?:(?:-| |)\d{4})?", re.IGNORECASE)
each = ''Expiration Date:\n05/31/1996\nBusiness Address: 23901 CALABASAS ROAD #2000 CALABASAS, CA 91302\n'
if RE_Add0.match(each):
    result0 = RE_Add0.match(each).group(0)
    print result0
    if len(result0) < 100:
        result.append(result0)
    else:
        print 'Address ignore'
else:
    None

© Stack Overflow or respective owner

Related posts about python

Related posts about regex