Jump to content

PkraM

New Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About PkraM

  • Rank
    Newbie
  1. From: To: Array ( [0] => License Number:AG013440 [1] => Expiration Date:11/19/2018 [2] => State Issued:CA ) Array ( [0] => License Number [1] => AG013440 ) <h1>AG013440</h1> Array ( [0] => AG013440 [1] => AG [2] => 013440 ) <h1>The numbers: 013440</h1> Code: <?php $startString = "[License Number:AG013440-Expiration Date:11/19/2018-State Issued:CA]"; $test1 = explode("-", $startString); print_r($test1); $plate = explode(":", $test1[0]); print_r($plate); echo "<h1>{$plate[1]}</h1>\n"; $test2 = preg_match("/^([A-Za-z]{2})([0-9]{1,10})$/", $plate[1], $matches); print_r($matches); echo "<h1>The numbers: {$matches[2]}</h1>\n";
  2. I have made some Regex to match UK number plates...shouldn't take much to make it suit your needs... $this->regexPatterns[] = array( 'name' => "1to31to31", 'pattern' => "/^([A-Z]{1,3})(\s)?(\d{1,3}[A-Z]{1})$/", 'desc' => "Contains between 1 and 3 letters followed by an optional space and between 1 and 3 numbers followed by a single letter" ); // (A1ABC) (A12ABC) (A123ABC) (A1 ABC) (A12 ABC) (A123 ABC) $this->regexPatterns[] = array( 'name' => "11to31to3", 'pattern' => "/^([A-Z]{1}\d{1,3})(\s)?([A-Z]{3})$/", 'desc' => "Contains 1 letter followed by between 1 to 3 numbers followed by optional space and then 3 letters" ); // (1A) (12AB) (123ABC) (1 A) (12 AB) (123 ABC) $this->regexPatterns[] = array( 'name' => "1to31to3", 'pattern' => "/^([A-Z]{1,3})(\s)?(\d{1,3})$/", 'desc' => "Contains between 1 and 3 letters, followed an optional space and then between 1 and 3 numbers" ); // (A1) (AB12) (ABC123) (A 1) (AB 12) (ABC 123) $this->regexPatterns[] = array( 'name' => "1to31to3", 'pattern' => "/^(\d{1,3})(\s)?([A-Z]{1,3})$/", 'desc' => "Contains between 1 and 3 numbers followed by an optional space and between 1 and 3 letters" ); // (AB12 ABC) $this->regexPatterns[] = array( 'name' => "223", 'pattern' => "/^([A-Z]{2}\d{2})(\s)?([A-Z]{3})$/", 'desc' => "Contains 2 letters followed by 2 numbers an optional space and then 3 letters" ); // (AB12 ABC) $this->regexPatterns[] = array( 'name' => "34", 'pattern' => "/^([A-Z]{3})(\s)?(\d{4})$/", 'desc' => "Contains 3 letters followed an optional space and then 4 numbers" );
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.