Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: simple regex pattern sought Date: Sat, 26 May 2012 16:37:09 +0200 Lines: 42 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net D5JRN21UKmqvhOYYLlWu6AHqri95+LC5KHZQZrXQO3jn+meW4UJ1z0RJosaVIEJzY= Cancel-Lock: sha1:4ixuGMFTsDIHHv+JO4KyquSxtQM= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:14813 On 26.05.2012 03:43, markspace wrote: > On 5/25/2012 3:12 PM, Robert Klemme wrote: > >> "\"(?:\\\\.|[^\\\"])*\"|'(?:\\\\.|[^\\'])*'" > > > This looks overly baroque to me. You don't need to escape \ single > quotes ' in a Java string, I didn't. > and I don't think you need to in a regex > either (although I didn't check that). There is also no regexp escaping of single quotes either. The only regexp escaping you can see are the \\\\ which translate into \\ in the string which is a literal backslash for the regexp engine. > I'm also not seeing the need for > the parenthesis around the character classes [] (but again, without > having tried it, I could be wrong). It's not parenthesis around character classes but around the alternative of "match a backslash followed by any char" and "any char which is not backslash or the opening quote type of this string variant". > And the dot . inside the parenthesis just looks wrong. It isn't - see above. > Great post overall though. Thank you! It does seem to need some time to sink in though... :-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/