Esempio n. 1
0
 protected function getWordsRegexp(array $words)
 {
     $expr = RegexpBuilder::fromList($words, $this->regexpOptions);
     $expr = \preg_replace('/(?<!\\\\)((?>\\\\\\\\)*)\\(\\?:/', '$1(?>', $expr);
     $regexp = new Regexp('/(?<![\\pL\\pN])' . $expr . '(?![\\pL\\pN])/Siu');
     $regexp->setJS('/(?:^|\\W)' . \str_replace('[\\pL\\pN]', '[^\\s!-\\/:-?]', $expr) . '(?!\\w)/gi');
     return $regexp;
 }
Esempio n. 2
0
 /**
  * Encode a Regexp object into JavaScript
  *
  * @param  Regexp $regexp
  * @return string
  */
 protected function encodeRegexp(Regexp $regexp)
 {
     return (string) $regexp->toJS();
 }
Esempio n. 3
0
 /**
  * @testdox getCaptureNames() returns the names of all captures
  */
 public function testGetCaptureNames()
 {
     $ap = new Regexp('#(?<year>\\d{4}) (?<name>[a-z]+)#');
     $this->assertSame(['', 'year', 'name'], $ap->getCaptureNames());
 }
Esempio n. 4
0
 protected function encodeRegexp(Regexp $regexp)
 {
     return $regexp->getJS();
 }