in reply to Re^3: Regex not working
in thread Regex not working

If I hold the first post as input, then your last post as correct output, I too get the expected output...

!/usr/bin/perl use strict; use warnings; my $text; while($text=<DATA>){ $text =~ s~<font color=("|')?((\w|\s)+)("|')?>(.*?)<\/font>~\[ +color=$2\]$5\[/color\]~ig; print $text . "\n"; } # expected output: # [color=blue]<i><b> <br>Some text[/color], <br>an a __DATA__ <font color="blue"><i><b> <br>Some text</font>, <br>an a

Yields:

[color=blue]<i><b> <br>Some text[/color], <br>an a

Can you, maybe, explain in words? or have a larger sample set. Do you mean that this works, but when it is multi-line, then it doesn't match?

Replies are listed 'Best First'.
Re^5: Regex not working
by Beaker (Beadle) on Jul 17, 2015 at 19:24 UTC
    Thanks, I wonder then if it could be an encoding issue with my input, not sure the best way to check that.