re behaving strangely

Discussion in 'Python' started by Josh Close, Jun 9, 2005.

  1. Josh Close

    Josh Close Guest

    This is not returning a match

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

    Anyone know why this is?

    --
    -Josh
     
    Josh Close, Jun 9, 2005
    #1
    1. Advertising

  2. Josh Close

    Peter Hansen Guest

    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
     
    Peter Hansen, Jun 9, 2005
    #2
    1. Advertising

  3. Josh Close

    Josh Close Guest

    Thanks for pointing out my utter stupidity :)

    It's been a long day.

    -Josh

    On 6/9/05, Peter Hansen <> 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
     
    Josh Close, Jun 9, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?q?Nils Hedstr=f6m

    Stateserver behaving strangely

    =?iso-8859-1?q?Nils Hedstr=f6m, Feb 11, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,033
    =?iso-8859-1?q?Nils Hedstr=f6m
    Feb 11, 2005
  2. Travis Whitton

    IO.seek behaving strangely on FreeBSD 4.9

    Travis Whitton, Apr 1, 2004, in forum: Ruby
    Replies:
    5
    Views:
    205
    Yukihiro Matsumoto
    Apr 2, 2004
  3. Ciaran

    Regexp replace behaving strangely?

    Ciaran, Jul 19, 2009, in forum: Javascript
    Replies:
    3
    Views:
    120
  4. Jadhav, Alok
    Replies:
    9
    Views:
    314
    Thomas Rachel
    Nov 15, 2012
  5. Jadhav, Alok
    Replies:
    0
    Views:
    256
    Jadhav, Alok
    Sep 17, 2012
Loading...

Share This Page