Example #1
0
 public function find($text)
 {
     $charPositions = $this->scanCharPositions($text);
     $tokens = array();
     foreach ($charPositions as $pos) {
         $token = StringUtil::findToken($text, $pos);
         if ($token !== null) {
             $tokens[] = $token;
         }
     }
     foreach ($tokens as $j => $token) {
         if (!$this->validator->isValid($token->getCoveredText($text))) {
             unset($tokens[$j]);
         }
     }
     return array_values($tokens);
 }
Example #2
0
 public function find($text)
 {
     $atCharPositions = array();
     $tokens = array();
     for ($i = 0; $i < strlen($text); $i++) {
         if ($text[$i] === '@') {
             $atCharPositions[] = $i;
         }
     }
     foreach ($atCharPositions as $pos) {
         $token = StringUtil::findToken($text, $pos);
         if ($token !== null) {
             $tokens[] = $token;
         }
     }
     foreach ($tokens as $j => $token) {
         if (!$this->validator->isValid($token->getCoveredText($text))) {
             unset($tokens[$j]);
         }
     }
     return array_values($tokens);
 }