in reply to Re: Regex + substring
in thread Regex + substring

Sorry I just coppied the the code without looking at the text. When "-" is encounter the output would have to be the same with just the - included i.e.

$O = "AAABBBCCCDDD"; $Mod = "BbBCc-C"; $Result = "aaaBbBCc-Cddd";

Replies are listed 'Best First'.
Re^3: Regex + substring
by AnomalousMonk (Archbishop) on Mar 27, 2012 at 16:24 UTC

    Maybe:

    >perl -wMstrict -le "my $orig = 'fEEfoobarFIEFOOBARFoEfOoBaRfUM'; my $mod = 'Foo-Bar'; ;; (my $modmod = $mod) =~ tr/-//d; my $new = join $mod, map lc(), split /\Q$modmod\E/i, $orig, -1; print qq{'$new'}; " 'feeFoo-BarfieFoo-BarfoeFoo-Barfum'