in reply to Regex not working

"Not working" is not helpful. What output do you desire? What output are you getting? We can be much more helpful when there's less guessing involved!

Dum Spiro Spero

Replies are listed 'Best First'.
Re^2: Regex not working
by Beaker (Beadle) on Jul 17, 2015 at 16:08 UTC

    Not working in that nothing changes with the input

    Desired output from

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

    would be..

    [color=blue]<i><b> <br>Some text[/color],  <br>an a
      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.

        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?

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