Python regex not working in code -



Python regex not working in code -

i've uploaded here..

http://regex101.com/r/hc2eh3/1

let email.body =

> from: "fasttech" <support@fasttech.com> > > == ship == > illustration name > > shipping via registered airmail w/tracking > > == shipping eta == > > == items ordered == > > == other services == > > > == order total == > $2.63 > > > > > give thanks 1 time again choosing fasttech. > > kind regards, > > fasttech team > > > fasttech - gadget , electronics > http://www.fasttech.com > support@fasttech.com > > > email automatically generated

i can't work in script - using code:

regex = r'> == ship == *\n. (\w+\s\w+)' link = re.findall(regex, email.body) print link

print link returns

[]

when should matching 'example name'

your regex works fine me.

>>> import re >>> s = """> from: "fasttech" <support@fasttech.com> ... > ... > == ship == ... > illustration name ... > ... > shipping via registered airmail w/tracking ... > ... > == shipping eta == ... > ... > == items ordered == ... > ... > == other services == ... > ... > ... > == order total == ... > $2.63 ... > ... > ... > ... > ... > give thanks 1 time again choosing fasttech. ... > ... > kind regards, ... > ... > fasttech team ... > ... > ... > fasttech - gadget , electronics ... > http://www.fasttech.com ... > support@fasttech.com ... > ... > ... > email automatically generated """ >>> m = re.findall(r'> == ship == *\n. (\w+\s\w+)', s) >>> m ['example name']

or

you may seek this. single space match space \s* match 0 or more spaces. it's improve utilize \s* instead of space.

>>> m = re.findall(r'^\s*>\s*==\s*ship\s*to\s*==\s+>\s*(\w+\s\w+)', s, re.m) >>> m ['example name']

python regex

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -