again problem with re.reserch

chris liechti cliechti at mails.ch
Tue Jul 31 00:07:11 EDT 2001


"sdf" <wqh-2 at 263.net> wrote in news:mailman.996548997.18654.python-
list at python.org:
>>>>> c = a.search('foo abcd')
>  print c
>  <SRE_Match object at 0x8114a28>
>  
> then how I can get the exact postion the string in 'foo abcd',
> for example ,I want it return a number denote the postion
> 

you dont need "re" for that. try find, like:
a = "that's a string"
pos = a.find('str')

if you realy insist on using regular expressions for that use ".start()" on 
the match object.

-- 
chris <cliechti at mails.ch>




More information about the Python-list mailing list