On 9/8/07, Zentrader <[EMAIL PROTECTED]> wrote:
> Same solution as above, but if you just want "Hello" and to not
> include words containing "Hello", i.e. "Helloing" or "Unhello", then
> you want to include a leading and/or trailing space.

You can also use the re (regular expression) module to search for
"hello" and make sure it's a complete word. You would use re to search
for something like "\bhello\b". "\b" being regex for an empty string
that only occurs at the start or beginning of a word.

More information on python regexes here: http://www.amk.ca/python/howto/regex/

Here is an example from that page:

>>> p = re.compile(r'\bclass\b')
>>> print p.search('no class at all')
<re.MatchObject instance at 80c8f28>
>>> print p.search('the declassified algorithm')
None
>>> print p.search('one subclass is')
None
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to