[Tutor] search and replace
tak
tak at dfx.co.jp
Tue Mar 7 04:57:49 CET 2006
Hello,
I have a problem finding specific words.
I would like to filter out a word or replace it in a file.
I notices that the re module is good for finding patterns.
I am trying to filter out a word from strings, but having a little trouble.
I was wondering if I can search a string for a specific word and nothing
else.
For example:
hello, Othello. # just the hello and not Othello
I know that I could probably put the string in a list and replace it.
But I was wondering if it is possible using re module or the other find
type attributes to find it.
hello will not be necessarily at the beginning or end, so I am opting
not to use endswith or startswith.
Thank you.
Best regards,
tak
More information about the Tutor
mailing list