Java reg exp question

L

laredotornado

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
 
E

Eric Sosman

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()
}
 
R

Roedy Green

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top