re. module

Emile van Sebille emile at fenx.com
Wed Nov 14 16:49:41 CET 2001


"Adrian Leu" <AdrianLeu at kelseus.com> wrote in message
news:993ae4ca.0111140731.3c11e6d5 at posting.google.com...
> I am trying to figure out a solution for the following:
>
> import re
>
> text = 'name_0 goto place'
> string = 'name|name_0|name_1'
>
> pattern = re.compile(string, re.I)
> d = pattern.search(text)
> return d.group(0)
>
> The problem is that my program will return 'name' to this. What I want
> is for the search to return a match (if it exists) only after looking
> at the whole string (name_0 in this case). I.e. in my example I would
> like the program to return 'name_0' not 'name'.
>
> Any ideas how I could do that?
>

Also match the space character that follows the identifier?

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list