In article <005801c08668$e0459070$0201010a@shaggy>, "Jamie Burns"
<[EMAIL PROTECTED]> wrote:
I tried something like this and your examples worked:
$str = "<tag element = \"value\" nextelement>";
if (eregi("=[[:space:]]*\"([^\"]+)|=[[:space:]]*([[:alnum:]]+)",$str,$regs)) {
print("yes - ".$regs[1].":".$regs[2]."<br>\n");
}
since the pattern has an 'or' (|), you have to look in either the second
or the third element of the array you use to store values from the ereg.
Jeff
> can anyone help me figure out a regular expression to find the value of
> a tag element?
>
> for example:
>
> <tag element="my value">
> <tag element=value>
> <tag element="my value" nextelement>
> <tag element=value nextelement>
> <tag element = "my value">
> <tag element = value>
> <tag element = "my value" nextelement>
> <tag element = value nextelement>
>
> so in each of the above i need to find either "my value" or "value"...
>
> i tried this but it wont work for every situation:
>
> ereg("element[ ]*[=][ ]*[\"]?([^\">]*)[ |\"|>].*" ...
>
> thanks for your help - regular expressions are not my best area!
>
> jamie.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]