You are almost there but not quite... $string =~ s/\~(.*)\~/<i>$1<\/i>/g;
Should do the trick. All I do is capture the "someString" part and rewrite it (it is stored in $1 for the first capture and $2 for the second and so on..) This way ~anystring~ will be replaced with <i>anyString</i> There is one more addition I would make though: $string =~ s/\~(.*?)\~/<i>$1<\/i>/g; That questionmark causes the regular expression to be non greedy what that means you can see below a ~string~ with two ~strings~ and some more text With the fisrt option you would end up with: a <i>string~ with two ~strings</i> and some more text Because perl regular expressions try and match as much as possible being greedy. The second option would result in: a <i>string</i> with two <i>strings</i> and some Whis is I thik what you are looking for. Regards, Rob On Mon, Sep 22, 2008 at 11:51 AM, Farrell, Patrick <[EMAIL PROTECTED]>wrote: > > I want to replace all instances of > > ~someString~ > > in a larger string with > > <i>someString</i> > > > I tried the following statement: > > $string =~ s/\~.*\~/<i>.*<\/i>/g; > > But what I get is a bunch of the following as the replacements: > > <i>.*</i> > > How do I retain the original .* in the replacement? > > Thanks > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > >