I'm having problems coming up with a regular expression that works for what
I want. I need to extract a few numbers from from html. Here's a snippet:
<tr><td align="right">C onsolidated Metro Area (CMSA)</td><td
align="left"><s trong> SEATTLE-TACOMA-BREMERTON, WA
( 7602 )</td></tr>
<tr><td align="right">P rimary Metro Area (PMSA)</td><td
align="left"><s trong>SEATTLE-BELLEVUE-EVERETT, WA
( 7600 )</td></tr>
What I am trying to do is extract the first 4 digit number that occurs after
the letters (CMSA) and the first 4 digit number that occurs after (PMSA).
In Dreamweaver, I am able to use the following reg ex to search and it works
fine:
\(CMSA\).*\d{4}
When I try to use the same reg ex in the code on a page it fails to make a
match:
$getCMSA = eregi("\(CMSA\) .*\(\s*\d{4}",$ result,$CMSA_va lue);
I want the reg ex to be as flexible as can be with the code (the least
amount of literal character searches) it is searching so if the site the
values are being pulled from ever changes their code slightly, there will be
a higher chance of the reg ex still working.
Can anybody help me out here? It would be GREATLY appreciated. Thanks!
I want. I need to extract a few numbers from from html. Here's a snippet:
<tr><td align="right">C onsolidated Metro Area (CMSA)</td><td
align="left"><s trong> SEATTLE-TACOMA-BREMERTON, WA
( 7602 )</td></tr>
<tr><td align="right">P rimary Metro Area (PMSA)</td><td
align="left"><s trong>SEATTLE-BELLEVUE-EVERETT, WA
( 7600 )</td></tr>
What I am trying to do is extract the first 4 digit number that occurs after
the letters (CMSA) and the first 4 digit number that occurs after (PMSA).
In Dreamweaver, I am able to use the following reg ex to search and it works
fine:
\(CMSA\).*\d{4}
When I try to use the same reg ex in the code on a page it fails to make a
match:
$getCMSA = eregi("\(CMSA\) .*\(\s*\d{4}",$ result,$CMSA_va lue);
I want the reg ex to be as flexible as can be with the code (the least
amount of literal character searches) it is searching so if the site the
values are being pulled from ever changes their code slightly, there will be
a higher chance of the reg ex still working.
Can anybody help me out here? It would be GREATLY appreciated. Thanks!
Comment