J. Patrick Lanigan writes ..
>> I was using:
>>
>> $mystring =~ s/\'/\\'/;
>>
>> ...to replace ' with \' in $mystring. It was working find I
>> thought, until I
>> encountered a string with multiple apostrophies. How do I replace
>> 0 or more?
>>
>> Ex:
>>
>> "No More 'I Love You's'"
>>
>> ...should become:
>>
>> "No More \'I Love You\'s\'"
>>
>> I've tried:
>>
>> $mystring =~ s/\'*/\\'/;
>> $mystring =~ s/(\')*/\\'/;
>>
>> ...neither of which work.
you need the global modifier .. what you're trying to do is do the current
match globally throughout the whole string (not zero or more)
$mystring =~ s/\'/\\'/g;
--
jason king
In New York, a fine of $25 can be levied for flirting. This old law
specifically prohibits men from turning around on any city street and
looking "at a woman in that way." A second conviction for a crime of
this magnitude calls for the violating male to be forced to wear a
"pair of horse-blinders" wherever and whenever he goes outside for a
stroll. - http://dumblaws.com/