Source Code:
(back to article)
<?php $pattern = '/^(.*)(\d{4})$/'; $string = 'This is a test 1234'; if (preg_match($pattern, $string, $matches)) { echo 'Match found.'; } else { $error = preg_last_error(); echo 'Error code: ' . $error; }
Result:
Report an issue