From: Aldric Giacomoni Date: 2009-10-21T00:35:19+09:00 Subject: Re: Complex GSUB query Ne Scripter wrote: > > string = "\"bloggs, Joe (JBloggs, INFO)\" joebloggs, \"bloggs, Bill > (BBloggs, INFO)\" billbloggs" > > I want to break this string up into two entries using a _ seperator, one > for Joe and the other for Bill. I could do this with a simple > > string.gsub(",", "_") > > However the problem with doing this is that there are commas elsewhere > in the string. So what I need to say is, if the comma is outside of "" > (quotes) replace it with the _ > > Could anyone possibly help me with this? > > Thanks I'd do: string.gsub!(", \"", "_ \"") # If the comma is followed by a space and double quotes, replace that with an undersore, a space and a double quote. But that's because I'm really lazy. -- Posted via http://www.ruby-forum.com/.