On Thu, 19 Aug 2004 15:53:28 +0100, Ian Richardson <za*****@chaos.org.uk>
wrote:
[snip]
I was really hoping for a regular expression to do extract multiples of:
7 digits and 7 digits separated by " - "
(HTML I'm not interested in)
Either 2 digits, or 2 digits followed by " - " and another 2 digits
(HTML I'm not interested in)
1 digit
...from within an HTML table, the markup of which can change...
Alberto's suggestion is a good start, but it depends on whether the
mark-up can contain numbers itself. If it can, there needs to be more
structure in the expression. Try:
/(\d{7}) - (\d{7})\x3c.+\x3e(\d{2})( - (\d{2}))?\x3c.+\x3e(\d)/
When used with the exec() method, it will return an array that contains:
element 0 - ignore
1 - first group of seven digits
2 - second group
3 - first group of two digits
4 - ignore
5 - second group of two digits
(undefined if they don't exist)
6 - final digit
This appears to be safe, even if numbers appear in the separating HTML,
but without live data, I can't test properly.
Give it a try. If it doesn't work and you can't modify the expression,
show the exact test case you used and we will see what we can do.
Good luck,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.