in reply to Re^2: Regular Expression Doubt
in thread Regular Expression Doubt
You lost a < here.my $text = '1 + 2 <br> <maths> + dfdf</maths>'; my $output = ""; while ($text =~ m/((<maths>.*?<\/maths>)|([^<]*))/gs) { if ($2) { $output .= $2; } else { my $segment = $3; $segment =~ s/+/ + /g; $output .= $segment; } } print $output . "\n"; __END__ 1  +  2 br> <maths> + dfdf</maths>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Regular Expression Doubt
by reasonablekeith (Deacon) on Apr 05, 2005 at 15:09 UTC | |
by Anonymous Monk on Apr 06, 2005 at 08:41 UTC |