Google Ads

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


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

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.

 

 
 
  1. <?php
  2. // create a string
  3. $string = 'Ronard';
  4. //display the string Ronard
  5. echo "<b>String is: </b>".$string."<br/>";
  6. // try to match our pattern at the end of the string
  7. if(preg_match("/nard\z/i", $string)) {
  8. // if our pattern matches we echo this
  9. echo 'The string ends with nard';
  10. } else {
  11. // if no match is found we echo this line
  12. echo 'No match found';
  13. }
  14. ?>

 

 

The above script will generate “The string ends with nard” which is read at the end of the subject.

 

 


Related Post

Wap5.in DxHost.Cu.Cc Hosting Site PHP Script Free ... Wap5.in DxHost.Cu.Cc Hosting Site PHP Script Free Download The most feature-rich free web hosting service you can find. If you try it, you will LOV...
Videoflix v1.3 – Tv Series Movie Subscriptio... Videoflix is a subscription based video content management system. Create your own movie & tv series website using videoflix. Sale them to your cu...
Client FTP Net Library PHP Script Download Client FTP Net LibraryClient FTP Net LibraryClient FTP Net Library born from the experience of over 15 years in the programming world of its creator. ...
Veno File Manager – host and share files PHP... Veno File Manager - host and share files Veno File Manager - host and share files If you are looking for a simple and flexible plug-and-play file mana...
Online Admission System PHP Script Online Admission System PHP Script The system involves the process of enrolling students into higher institution, payment verification using ...

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

"