Reputation: 3859
I want to form a pattern to match the word "Jason" in the following string:
[LASTUSER=Jason;22]
Upvotes: 2
Views: 84
Reputation: 10174
$pattern = '%\\[LASTUSER=([^;]+?);[0-9]+\\]%i';
if(preg_match($pattern, $str, $matches)) {
$user = $matches[1];
}
Upvotes: 2
Reputation:
The following matches the name and the following number:
preg_match('/\[LASTUSER=([^;]*);(\d+)\]/', $str, $matches);
Upvotes: 3