[wplug] regex help

James O'Kane jo2y at midnightlinux.com
Mon Jan 12 18:45:03 EST 2004


On Mon, 12 Jan 2004, Brian Medley wrote:
> If so, then consider matching the following line:
> 
>     <td>One Cell</td><td>Two Cell</td>
> 
> I believe that /<td.*?>/ will find "<td>One Cell</td>" and /<td.*>/
> would match the entire line.  Basically, the way I think about it is
> that w/ greedy the beginning anchor is set as soon as possible and
> the ending anchor is set as late as possible.  With non-greedy, the
> beginning anchor is the same, but the ending anchor is set as soon as
> possible.

perl disagrees. # comments after the #'s


[jo2y at dax jo2y]$ perl -de 0  # -d starts the debugger -e 0 executes '0' 

Loading DB routines from perl5db.pl version 1.19
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(-e:1):   0
  DB<1> $|=1                          # Turn off IO buffering

  DB<2> $string = "<td>One Cell</td><td>Two Cell</td>"

  DB<3> $string =~ /(<td.*>)/ ; print $1
<td>One Cell</td><td>Two Cell</td>
  DB<4> $string =~ /(<td.*?>)/ ; print $1
<td>
  DB<5> 




-james





More information about the wplug mailing list