[Tutor] Help Python String Search
Kent Johnson
kent37 at tds.net
Tue Oct 7 03:59:19 CEST 2008
On Mon, Oct 6, 2008 at 5:37 PM, Deitemeyer, Adam R
<Adam.R.Deitemeyer at boeing.com> wrote:
> Hello,
>
> I'm a beginner Python user and I have simple python issue I can't seem to
> solve. I want to do a truth test on a string to see if a another string is
> contained within it. I found that typically the re module has the methods
> to accomplish this. However, every string I'm searching begins with a
> metacharacter. For example: if the string '*I need *help' contains the word
> 'help' then true, else false..
This would only be an issue with regexes if the pattern you are
searching for contained metacharacters. Then you would escape them.
But John's approach is simpler in this case.
Kent
More information about the Tutor
mailing list