views:

107

answers:

4

I want a regular expression that can match <FONT FACE=\"Verdana\" SIZE=\"12\"> My Name is xyz </FONT> or

<LI><FONT FACE=\"Verdana\" SIZE=\"12\"> My Name is xyz </FONT></LI> and it should not be greedy

+1  A: 

Why not use a Java XML parser?

treeface
I dont think its of any use
java_geek
What...Google is of no use? Perhaps the OP should've used Bing?
treeface
if you have a problem and solve it with a regular expression, now you have 2 problems. If you don't think HTML and XML parsers are of any use then you will never understand the reasons no body will answer your question with what you want ... because they can't.
fuzzy lollipop
@fuzzy Who are you talking to?
treeface
+2  A: 

You should not be using regular expressions for this

Woot4Moo
+6  A: 

Three questions in as many hours. Must be a record of some sorts.

For the sake of humanity, don't use regular expressions to parse XML!

Manoj Govindan
i am aware that u cannot parse HTML using regex.
java_geek
Is there then any specific reason why you are using regular expression to parse the HTML snippet?
Manoj Govindan
Yeah, i have a specific html file and i need to do some kind of manipulation on it. I am not looking for a generic html parser.
java_geek
Is there something in the 'specific' HTML file that a 'generic' XML/HTML parser cannot handle?
Manoj Govindan
all HTML parsers are specific to HTML. use an HTML parser, that is what they are for parsing all HTML.
fuzzy lollipop
A: 

You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool that is insufficiently sophisticated to understand the constructs employed by HTML. HTML is not a regular language and hence cannot be parsed by regular expressions. Regex queries are not equipped to break down HTML into its meaningful parts

the beginning of the answer to this exact question with over 3400 up votes. If you don't understand this and insist on ignoring this advice then you probably should not be programming.

fuzzy lollipop