[Tutor] Grep equiv.

Rick Pasotto rick@niof.net
Thu, 31 Aug 2000 15:19:50 -0400

On Thu, Aug 31, 2000 at 01:20:30PM -0400, Michael P. Reilly wrote:
> > 
> > > Is there a nice, easy, fast way of saying "if this
> > > line/string/variable/array/whatever contains 'xxx' then do 
> > > 'something'"
> > 
> > For literal strings use string.search()
> > 
> > For regular expressions use re.search()
> There is also the "grep" module which gives you differing types of
> regular expressions (does not support pcre).
> If there is no need to use regular expressions, then use the string
> module.  The overhead (even in Perl) of using a regular expression
> engine is not always desirable.

If there is no need for regular expressions and all he needs to know is
true/false is there any reason not to use:

if word in string:

"Prohibition...goes beyond the bounds of reason in that it attempts to
control a man's appetite by legislation and makes a crime out things
that are not crimes. A prohibition law strikes a blow at the very
principles upon which our government was founded."
		-- Abraham Lincoln, Dec. 1840
		   Rick Pasotto email: rickp@vnet.net