[Solved] Regular expression to extract id from email subject [closed]


Use /(?<=\[ID:)\d+/ pattern that match digits that is after [ID: string.

$subject = "New tour subscription [ALKJ-102] [ID:12345]";
preg_match("/(?<=\[ID:)\d+/", $subject, $mat);
echo $mat[0];

Check result in demo

1

solved Regular expression to extract id from email subject [closed]