Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.programmer Subject: Re: Regex? Date: Wed, 25 Jun 2014 18:10:51 -0700 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <3rplq9hoa7vg9b7oq6iqh4e5iesatvg1f5@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 26 Jun 2014 01:10:42 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="aba33539224e5c782fe0c4053f7756fd"; logging-data="23812"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OQ/J+KB4+7OsadTDU3O8J" User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <3rplq9hoa7vg9b7oq6iqh4e5iesatvg1f5@4ax.com> Cancel-Lock: sha1:5tSDVv8QFko96zCRty/Oy07Iy3w= Xref: csiph.com comp.lang.java.programmer:28856 On 6/25/2014 08:15, Roedy Green wrote: > On Fri, 20 Jun 2014 15:46:13 -0700, Knute Johnson > wrote, quoted or indirectly quoted someone > who said : > >> Well I've been round and round on this, I thought originally that I >> could find all the examples of the search string with one call to >> Matcher.matches() but I can't figure out how to do that > > I have examples of use of all the regex methods in little SSCCEs. > > See http://mindprod.com/jgloss/regex.html > Thanks I'll take a look. I think what I thought I could do is not possible. Apparently you can't get multiple capture groups without multiple sets of parenthesis. I thought I could do something like; Pattern.compile("(the)*") and capture all of the 'the's in the string in their own group. But as it turns out each group must have its own set of parenthesis. So instead of that approach I decided to use Matcher.find() to search through the string and keep a list of the matches. I'll post some code once I've got it cleaned up and debugged. -- Knute Johnson