Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with regex to find address

Status
Not open for further replies.

ehicks727

Programmer
Oct 26, 2004
36
0
0
US
Hi, I have a recurring pattern like this...

Code:
</table>
              
              <br>                            
              
              <br>

              ACME Co.
              
              <br>
              123 Main St.
              
              <br>
              Smallville
              
              &nbsp;FL
              
              &nbsp;12345
              
                <br />

I am trying to figure out a regex that will find anything matching the table and two breaks, and then a wildcard, the nbsp another wildcard, the second nbsp, another wildcard, and then end on the closed br tag.

I hope that made sense.

I know this is TOTALLY wrong, but here's what I started with.

Code:
Pattern p = Pattern.compile("^.*</table><br><br>.*&nbsp;.*&nbsp;.*<br />$");
            Matcher matcher = p.matcher(html);
            if (matcher.matches()) {
                    System.out.println(matcher.group());
                }

I would greatly appreciate your help figuring this out. Thanks!
 
nevermind... I figured it out. Went a little old-school and used a lot of .indexOf()
 
Maybe if you're planning to do this very often you should consider parsing the XML.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top