From: laredotornado on 4 Feb 2010 12:50 Hi, I'm using Java 1.5. How do I find all strings matching a particular pattern in a larger string? For example, I have HTML page source, and I want to find all the names of the checkboxes where I'm guaranteed the checkboxes will appear on the page like so ... <input type="checkbox" value="true" name="invoicingReport:invoicingTable:1:_idJsp17"/> Thanks for your help, - Dave
From: Eric Sosman on 4 Feb 2010 13:25 On 2/4/2010 12:50 PM, laredotornado wrote: > Hi, > > I'm using Java 1.5. How do I find all strings matching a particular > pattern in a larger string? For example, I have HTML page source, and > I want to find all the names of the checkboxes where I'm guaranteed > the checkboxes will appear on the page like so ... > > <input type="checkbox" value="true" > name="invoicingReport:invoicingTable:1:_idJsp17"/> Compile your Pattern, get a Matcher from it, and call the Matcher's find() method in a loop until it returns false. Pattern patt = Pattern.compile("whatever", options); Matcher match = patt.matcher(theString); while (match.find()) { System.out.println(match.group()); // or use match.start(), match.end() } -- Eric Sosman esosman(a)ieee-dot-org.invalid
From: Roedy Green on 4 Feb 2010 15:23 On Thu, 4 Feb 2010 09:50:32 -0800 (PST), laredotornado <laredotornado(a)zipmail.com> wrote, quoted or indirectly quoted someone who said : > >I'm using Java 1.5. How do I find all strings matching a particular >pattern in a larger string? For example, I have HTML page source, and >I want to find all the names of the checkboxes where I'm guaranteed >the checkboxes will appear on the page like so ... See http://mindprod.com/jgloss/regex.html#FINDING -- Roedy Green Canadian Mind Products http://mindprod.com You can�t have great software without a great team, and most software teams behave like dysfunctional families. ~ Jim McCarthy
|
Pages: 1 Prev: web sites for sale $200 only each one Next: Protected nested generic constrained inheritance |