From: David Alan Black Date: 2004-05-13T20:23:55+09:00 Subject: Re: nasty regexp problem Hi -- Simon Strandgaard writes: > Francis Hwang wrote: > > I discovered a strange bug in Lafcadio which I'm trying to work out, > > but the regexp is getting really nasty. Basically, to commit text > > values to the database I need to double any apostrophe, except those > > that are preceded by a backslash. This has to account for apostrophes > > at the beginning of the string, and multiline strings where the > > apostrophe is at the start of a new line. Examples would be: > > > irb(main):001:0> "''\\\\'z\\'\\z''".gsub(/ ( (?: [^\\] | \\ . )*? ) ' /x, '\1\'\'') > => "''''\\\\''z\\'\\z''''" The ' before the first z isn't supposed to get doubled though, is it? David -- David A. Black dblack@wobblini.net