AdrianLeu at kelseus.com
Thu Nov 15 12:16:28 CET 2001
"Emile van Sebille" <emile at fenx.com> wrote in message news:<9su44o$163aq9$1 at ID-11957.news.dfncis.de>...
> "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?
NO, just match the string.
More information about the Python-list