View Single Post
Old 09-20-2010, 05:02 AM   #4
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,896
Karma: 1216548
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by ldolse View Post
A few other useful expressions:
Matching p tags with any styles/ids:
<p[^]*>
Don't you mean '<p[^>]*>'? Also, this won't work if any of the internal attributes contain a > character. Consider <p foo=">">.

This exposes one of the problems with regular expressions. Using regexps, it is difficult to do delimited matching in the constrained case, and impossible in the general case. Doing it right usually requires a recursive state machine, which by definition cannot be described by a regular expression. For fun, try to write a regular expression that matches any palindrome. (http://en.wikipedia.org/wiki/Palindrome. Examples: abcdedcba or 'madam im adam' with spaces ignored.) You will fail.

Edit: the paragraph above deals with computational theory and does not belong in a tutorial. However, it might be useful for Manichean, which is why I added it.

Last edited by chaley; 09-20-2010 at 05:06 AM.
chaley is offline