Reputation: 433
This is my text:
pagination},queryId:"472f257a40c653c64c666ce877d59d2b", val:"598f257a40c653c64c666ce877d59d2b"
I need to find 472f257a40c653c64c666ce877d59d2b and 598f257a40c653c64c666ce877d59d2b.
These are all between ". I need ONLY strings between " ", and which don't exceds 32.
Here is my code:
preg_match_all('/"^(.*?){32}$"/mis', $get, $results);
Upvotes: 0
Views: 120
Reputation: 163352
You could use :"\K[a-f\d]{32}(?=")
Explanation
:"
\K
[a-f\d]{32}
(?=")
For example:
$re = '/:"\K[a-f\d]{32}(?=")/';
$str = 'pagination},queryId:"472f257a40c653c64c666ce877d59d2b", val:"598f257a40c653c64c666ce877d59d2b"';
preg_match_all($re, $str, $matches);
var_dump($matches[0]);
That would result in:
array(2) {
[0]=>
string(32) "472f257a40c653c64c666ce877d59d2b"
[1]=>
string(32) "598f257a40c653c64c666ce877d59d2b"
}
Upvotes: 1
Reputation: 3405
Regex: "([a-z0-9]{32})"
or (?<=")[a-z0-9]{32}(?=")
$text = "pagination},queryId:\"472f257a40c653c64c666ce877d59d2b\", val:\"598f257a40c653c64c666ce877d59d2b\"";
preg_match_all("/\"([a-z0-9]{32})\"/", $text, $match);
print_r($match);
Output:
Array
(
[0] => Array
(
[0] => "472f257a40c653c64c666ce877d59d2b"
[1] => "598f257a40c653c64c666ce877d59d2b"
)
[1] => Array
(
[0] => 472f257a40c653c64c666ce877d59d2b
[1] => 598f257a40c653c64c666ce877d59d2b
)
)
Upvotes: 0