[Israel.pm] A simpler regex required

Shlomi Fish shlomif at iglu.org.il
Wed Aug 15 07:57:25 PDT 2007


Hi all!

On Wednesday 15 August 2007, Yitzchak Scott-Thoennes wrote:
> On Tue, August 14, 2007 7:22 am, Peter Gordon wrote:
> > s!(<td.*?>)(.*?)(</td>)!my $t1 = $1 ;my $t2 = $2 ; my $t3 = $3 ; $t2 =~
> > s/\s/&nbsp;/g ; "$t1$t2$t3" ;!egs ;
>
> Is there a reason not to just:
>
> s{(<td.*?>)([^ ]+) ([^ ]+) ([^ ]+) ([^ +)(</td>)}
>  {$1$2&nbsp;$3&nbsp;$4&nbsp$5$6}g
>

This will work only if there are exactly 4 words between the <td> and the 
</td>, and with a very particular arrangement of whitespace and 
non-whitespace characters.

As such it is not recommended to use this regex.

Regards,

	Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish      shlomif at iglu.org.il
Homepage:        http://www.shlomifish.org/

If it's not in my E-mail it doesn't happen. And if my E-mail is saying
one thing, and everything else says something else - E-mail will conquer.
    -- An Israeli Linuxer



More information about the Perl mailing list