converting perl to python - simple questions.

Randal L. Schwartz merlyn at stonehenge.com
Thu Apr 29 10:26:22 EDT 1999


>>>>> "Tim" == Tim Peters <tim_one at email.msn.com> writes:

Tim> Perl actually has the same problem, but it's *usually* hidden by "regexp
Tim> context"; e.g.;

Tim>     $string =~ /\bthe/

Tim> matches "the" starting at a word boundary, while

Tim>     $pattern = "\bthe";
Tim>     $string =~ /$pattern/

Tim> matches "the" following a backspace character.

Oddly enough, these *will* match word boundaries:

	$pattern = '\bthe';

	$pattern = qr/\bthe/;

Yes, Perl is heavily context sensitive... and so are human beings. :)

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn at stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn at teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me




More information about the Python-list mailing list