PHP Quantifiers For Matching Recurring Character – String Function

 
Symbol         Description                                      Example
 
*              Zero or more instances                           a*
 
+              One or more instances                            a+
 
?              Zero or one instance                             a?
 
{n}            n instances                                      a{3}
 
{n,}           At least n instances                             a{3,}
 
{,n}           Up to n instances                                a{,2}
 
{n1, n2}       At least n1 instances, no more than n2 instances a{1,2}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.