[Tutor] Grep equiv.
Thu, 31 Aug 2000 17:33:11 +0100
> Is there a nice, easy, fast way of saying "if this
> line/string/variable/array/whatever contains 'xxx' then do
For literal strings use string.search()
For regular expressions use re.search()
if re.search('[pP]ython','My python script'):
print 'found it!'
There are also substitution functions for search/replace operations...
Read the re module docs.
> With something being spit it out, return true, or whatever. Doesn't
> Anyhow, thanks for any help :)
> A struggling python beginner, trying to buck the system in a
> building full
> of c, perl, awk, java, and other assorted programmers - none
> of whom use
> python (yet ;) )