Code: Select all
<?php
$text = "AB-12345";
if(preg_match("/^([A-Za-z]+)\-([0-9]+)$/", $text)){
echo "yes";
}
?>Thanks!
Moderator: General Moderators
Code: Select all
<?php
$text = "AB-12345";
if(preg_match("/^([A-Za-z]+)\-([0-9]+)$/", $text)){
echo "yes";
}
?>[0-9]{1,5}http://www.perl.com/doc/manual/html/pod/perlre.html wrote:The following standard quantifiers are recognized:
* Match 0 or more times
+ Match 1 or more times
? Match 1 or 0 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but not more than m times