in reply to replacing code with regex

I would suggest you make use of the x modifier, break your regex out on multiple lines, and put some comments in. If you've not figured it out for yourself by then (and I bet you will have) you'll get a much better response from people here.

HTH, Rob

---
my name's not Keith, and I'm not reasonable.

Replies are listed 'Best First'.
Re^2: replacing code with regex
by raflach (Pilgrim) on May 11, 2005 at 17:38 UTC
    You overestimate me! Highly commented code still leaves me stumped. Anyone want to jump in here?
      As you followed my advice I could hardly not try and help!

      Anyway changing

      (\W*?) # this shouldn't be necessary since whitespace should have be +en slurped on previous line but this shouldn't hurt either
      ... to ...
      (\s*?) # this shouldn't be necessary since whitespace should + have been slurped on previous line but this shouldn't hurt either
      fixes it. Horrah. $1 printed 'isitvalid("templatefile.html")' when I tested it

      Anyway \s is a more standard way of matching whitespace, so I guess you could get milage out of changing all your instances of \W*?, which are probably matching more than you expect. Case in point.

      my $test = '{}[]£$%'; my $match = ($test =~ m/(\W*)/)[0]; print $match; __OUTPUT__ {}[]£$%
      ---
      my name's not Keith, and I'm not reasonable.