| Store | Cart

Re: Reg-ex: replacing HTML tag contents

From: Ian D. Stewart <i...@c-cor.com>
Tue, 27 Jun 2000 14:31:32 -0400
Lee Goddard wrote:
> > I'm trying to make this> >         Okay <TAG name="foo">Okay2</TAG> Okay3> > into this:> >         <i>Okay</i> <TAG name="foo"><i>Okay2</i></TAG> <i>Okay3</i>> > and I'm stuck.  Please help.  I've been trying all sorts of things....

How about: s{Okay\d?}{<i>$&</I>}g

test case follows:

#!C:\Perl\bin\perl.exe
use strict;

my $test = q(Okay <TAG name="foo">Okay2</TAG> Okay3);
print $test, "\n";
$test =~ s{Okay\d?}{<i>$&</i>}g;
print $test, "\n";



HTH,
Ian

-- 
99 little bugs in the code, 99 bugs in the code.
Fix one bug, compile again, 100 little bugs in the code.
100 little bugs in the code, 100 bugs in the code.
Fix one bug, compile again, 101 little bugs in the code...

Recent Messages in this Thread
Lee Goddard Jun 27, 2000 02:47 pm
Ian D. Stewart Jun 27, 2000 06:31 pm
Messages in this thread