tags:

views:

81

answers:

3

What benefits we can take using regex in xhtml css development?

any tools and useful regex commands?

+1  A: 

Do not use regex for parsing html.

Don't know about css though. It depends if it`s regular language or not. But it seems that parsing css with regexes aren't recommended too.

Arnis L.
We can wish for a perfect world. However, in the real world regex is often your only choice for isolating usefull elements within a web-page.
Hassan Syed
Luckily - I've always managed to runaway from this 'only choice'.
Arnis L.
lucky you, writing a generic spider sucks :D
Hassan Syed
@Hassan: That isn't "parsing HTML"; that's screenscraping, which is (by its nature) a volatile act that's not fault- or change-tolerant, and thus perfectly suited to regular expressions.
Adam Robinson
@Hassan this isn't true. If the HTML can be parsed at all there are several tools (Tidy, Tag Soup, Beautiful Soup, etc.) which will do the best possible job. If it can't be parsed by them then it's completely brokwn and you have not hope. XML tools are far better for isolating elements in context
peter.murray.rust
the original question has nothing to do with parsing ...
Hassan Syed
@Hassan: But this answer did, and that's what you responded to.
Adam Robinson
+1  A: 

See this answer, it says it all:

Regex and HTML

Lance Roberts
+2  A: 

HTML and CSS are not regular and cannot be parsed by regular experessions. (Some simple subsets may be parsable but they invariably break down). Open/free HTML parsers are available in almost every language (even FORTRAN). Most languages also support CSS parsers. There are so many pitfalls in trying to use regexes. Please don't

peter.murray.rust