Match at end of the string

PHP RegEx: Match a pattern at the end of the string

In previous tutorial we have a pattern that match a string at the beggining using caret(^). Now we try to match the pattern at the end of the string using \z. What is \z? This is end of subject or read at the end of subject. We still use (i) case insensitive modifier so that it can read any case. The above script will generate "The string ends with nard" which is read at the end of the subject.