By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,931 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,931 IT Pros & Developers. It's quick & easy.

re behaving strangely

P: n/a
This is not returning a match

re.compile( r'b' ).search( 'back', re.I )

Anyone know why this is?

--
-Josh
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Josh Close wrote:
This is not returning a match

re.compile( r'b' ).search( 'back', re.I )

Anyone know why this is?


Yes:
import re
re.compile(r'b').search('back', re.I)
re.compile(r'b').search('back') <_sre.SRE_Match object at 0x00AF3D78> re.compile(r'b', re.I).search('back') <_sre.SRE_Match object at 0x00AF3CD0> re.compile(r'b', re.I).search('KCAB')

<_sre.SRE_Match object at 0x00AF3DB0>

:-)

-Peter
Jul 19 '05 #2

P: n/a
Thanks for pointing out my utter stupidity :)

It's been a long day.

-Josh

On 6/9/05, Peter Hansen <pe***@engcorp.com> wrote:
Josh Close wrote:
This is not returning a match

re.compile( r'b' ).search( 'back', re.I )

Anyone know why this is?


Yes:
>>> import re
>>> re.compile(r'b').search('back', re.I)
>>> re.compile(r'b').search('back') <_sre.SRE_Match object at 0x00AF3D78> >>> re.compile(r'b', re.I).search('back') <_sre.SRE_Match object at 0x00AF3CD0> >>> re.compile(r'b', re.I).search('KCAB')

<_sre.SRE_Match object at 0x00AF3DB0>

:-)

-Peter
--
http://mail.python.org/mailman/listinfo/python-list

--
-Josh
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.