From: Simon Strandgaard Date: 2004-05-13T14:02:03+09:00 Subject: Re: nasty regexp problem 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''''" -- Simon Strandgaard