Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82109

Python re.search simple question

Date 2014-12-08 12:22 +0530
Subject Python re.search simple question
From Ganesh Pal <ganesh1pal@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16710.1418021565.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi Folks ,

This  might seem to be very trivial question but iam breaking my head over
it for a while .

 My understanding is that re.search should search for the match anywhere in
the string .


why is re.search failing in the below case  ??

>>> pattern
'Token-based migrations cannot be mixed with level-based: [prev 0 , now 1]'
>>> text
' LogMessage {type NDMP_LOG_DBG} {msg_id 0} {msg The process id for NDMP
service is 0x9c216370} {associated_msg 0} {associated_msg_seq 0} Source
filer:DartOS  Error: Token-based migrations cannot be mixed with
level-based: [prev 0 , now 1]'

>>> if (re.search(pattern,text)):
...    print "Hi"
... else:
...     print "BYE"
...
BYE

Regards,
Ganesh

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Python re.search simple question Ganesh Pal <ganesh1pal@gmail.com> - 2014-12-08 12:22 +0530
  Re: Python re.search simple question Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-12-08 09:08 +0200
    Re: Python re.search simple question Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-12-08 09:13 +0200
  Re: Python re.search simple question Denis McMahon <denismfmcmahon@gmail.com> - 2014-12-09 00:31 +0000

csiph-web