Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: simple regex pattern sought Date: Fri, 25 May 2012 15:03:29 -0700 (PDT) Organization: http://groups.google.com Lines: 23 Message-ID: <9c1a694e-cfe8-4fed-bdb2-0550c5c2d288@googlegroups.com> References: NNTP-Posting-Host: 69.28.149.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1337983502 336 127.0.0.1 (25 May 2012 22:05:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 25 May 2012 22:05:02 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 Xref: csiph.com comp.lang.java.programmer:14803 On Friday, May 25, 2012 2:55:07 PM UTC-7, Lew wrote: > Roedy Green wrote: > > I often have to search for things of the form > > > > "xxxxx" > > or > > 'xxxxx' > > > > where xxx is anything not " or '. It might be Russian or English or > > any other language. > > > > What is the cleanest way to do that? > > Use a regex like "[\"'][^\"']+[\"']" is one way. The cleanest? I don't know. "([\"'])[^\"']+\\1" That way you match the opening quote. (The extra backslashes are to escape the characters in the string. Regex sees one fewer per each set.) -- Lew