Skip to content

Commit

Permalink
regex changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
sayadaazami committed Oct 5, 2016
1 parent 949188b commit 4048054
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ Finally, run:
Ho to use:
====
```php
$plate_number = '12' .
'س' .
321 .
'ایران' .
. 22;
$plate = Plate::setPlate($plate_number);
$plate->getType(); // تاکسی
$plate->getState(); // تهران
$plate = new Plate\Plate();
$plak = 21 .
' ب ' .
488 .
' - ' .
88 .
' ایران';

$r = $plate->setPlate($plak);
print_r($r->getparsedData()); exit;
print_r($plate->isCab());
```
14 changes: 7 additions & 7 deletions src/Plate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ public function __construct(){
private function parse(){
preg_match($this->getRegEx(), $this->_plate, $matchs);

$stateNumber = $matchs[2];
$stateNumber = $matchs[4];
$stateName = $this->_getStateNameByNumber($stateNumber);
$character = $matchs[4];
$character = $matchs[2];

$this->_parsed = [
'cityName' => $this->_getCityNameByCharAndNumber($stateName, $character, $stateNumber),
'type' => $this->_getTypeByChar($character),
'char' => $character,
'2DigitNumber' => $matchs[3],
'3DigitNumber' => $matchs[5],
'countryName' => $matchs[1],
'2DigitNumber' => $matchs[1],
'3DigitNumber' => $matchs[3],
'countryName' => $matchs[5],
'stateNumber' => $stateNumber,
'stateName' => $stateName,
];
Expand Down Expand Up @@ -72,8 +73,7 @@ public function setPlate($plate){

public function getRegEx(){
$farsiChars = implode('|', array_keys($this->_suportedChars));
return "/(ایران) ([1-9]\d) \- ([1-9]\d) ({$farsiChars}) ([1-9]\d{2})/";
return "/([1-9]\d)({$farsiChars})([1-9]\d{2})(ایران)([1-9]\d)/";
return "/([1-9]\d{1})\s+({$farsiChars})\s+([1-9]\d{2})\s+\-\s+([1-9]\d{1})\s+(ایران)/";
}

public function validate($plate = null, $softCheck = false){
Expand Down

0 comments on commit 4048054

Please sign in to comment.