I have a variable which holds an html page, and I need to get a specific piece of data out of it. 2 pieces, to be more specific.
I know the data will always look like:
The name and number changes, however. The name can contain any numbers, letters, or spaces (but it cannot start with a space, of course). The number will always be 5 numbers between 0-9, enclosed in parenthesis.
To get the number, I use:
ereg("(([0-9]{5})) <", $content, $result);
Grabbing them seperately simplifies things, so now I only need to get the name out.
I was using something like:
Which worked fine, but it fails if the name contains any space. So while it could return a name like "POWER"; it would fail on "POW ER".
So, that's where I am now. I can get a name with no spaces just fine, but everything I try to get names with spaces seems to fail.
Returning a name with an extra space at the end or space at the begining would be fine. I could care less as long as it returns the whole name 🙂
On a similar note, if anyone knows a good reference for regular expressions, I'd love to have it. Printed material would be fine (like a book), but an internet site/file would be prefered. I'm going to have to use them way too often to have the simplest functions suffice.
Thanks!