View Single Post
Old 09-20-2010, 04:02 AM   #4
chaley
Wizard
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: 3,879
Karma: 285970
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
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.
__________________
Support calibre developers at no cost to you by using calibre's get books feature.
Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre
charles.haleys.org/calibre

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