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

Sorry struggling to use this website, can't seem to edit my post. The input is given in my first post, ignore the input in my second post as it's incorrect. The expected output is correct.

Replies are listed 'Best First'.
Re^4: Regex not working
by FreeBeerReekingMonk (Deacon) on Jul 17, 2015 at 17:59 UTC

    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?

      Thanks, I wonder then if it could be an encoding issue with my input, not sure the best way to check that.
Re^4: Regex not working
by stevieb (Canon) on Jul 17, 2015 at 17:58 UTC

    To edit your own posts, simply click on the title, and an edit box will appear at the bottom of your post.

      thanks