Re: Regex in if statement.

2011-03-20 Thread Thomas L. Shinnick
At 07:46 PM 3/20/2011, Ken D'Ambrosio wrote: Hey, all -- I know how to match and return stuff from a regex, but I'd like to do an if, something like (from Perl, sorry): if (/MatchTextHere/){DoSomething();} How do I accomplish this in Python? You say you've done matching and accessing stuff fr

Re: Regex in if statement.

2011-03-20 Thread Rhodri James
On Mon, 21 Mar 2011 00:46:22 -, Ken D'Ambrosio wrote: Hey, all -- I know how to match and return stuff from a regex, but I'd like to do an if, something like (from Perl, sorry): if (/MatchTextHere/){DoSomething();} How do I accomplish this in Python? The basic routine is to do the match

Re: Regex in if statement.

2011-03-20 Thread python
I agree with previous comments. There are plenty of good tutorials, I have sometimes found more useful for learning than the manuals. The manuals are good but I prefer examples. http://www.tutorialspoint.com/python/python_reg_expressions.htm http://www.awaretek.com/tutorials.html#regular Bill Sn

Re: Regex in if statement.

2011-03-20 Thread Terry Reedy
On 3/20/2011 8:46 PM, Ken D'Ambrosio wrote: Hey, all -- I know how to match and return stuff from a regex, but I'd like to do an if, something like (from Perl, sorry): if (/MatchTextHere/){DoSomething();} How do I accomplish this in Python? Look at the doc to see what are the possible return

Re: Regex in if statement.

2011-03-20 Thread Benjamin Kaplan
On Sun, Mar 20, 2011 at 8:46 PM, Ken D'Ambrosio wrote: > Hey, all -- I know how to match and return stuff from a regex, but I'd > like to do an if, something like (from Perl, sorry): > > if (/MatchTextHere/){DoSomething();} > > How do I accomplish this in Python? > > Thanks! > > -Ken > Python doe