I am trying to match a string like the following:
<input type="text" value="cbyEOS56RK3lOxtiCrhmWSkDuNWwrFN4" name="iden">
This is my code:
$pattern = '~value="(.+?)" name="iden"~';
preg_match($pattern, $page, $match);
print_r($match);
As you can probably see, I am trying to match the value in this HTML input. By what I know of regular expressions, .*
will match as many characters as possible until it satisfies the next token (in this case "
).
I have the name="iden"
part in my regex because there are other HTML inputs on the page and I only want to match this one.
Problem is, I'm not getting any matches at all. $match
is an empty array. And I know that $page
has the right content because I can see it when I echo it.
Help fixing my regex is appreciated, thanks.