From: Alex Young Date: 2006-08-20T01:10:57+09:00 Subject: Re: Match all occurance of double quotes in a string Patrick Spence wrote: > I have a string something like this... > "Now is the time for all good men to blah, blah..." - Origin unknown > > I want to convert it to this... > [i]Now is the time for all good men to blah, blah...[/i] - Origin > unknown > > With the first double quote converted to "[i]" and the second to "[/i]". > The occurance of the 1st double quote may or may not be at the beginning > of the string. > > Rather simplistic, but should work: string.sub(/"([^"]*)"/, '[i]\1[/i]') -- Alex