示例#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;
 }
示例#2
0
 /**
  * Encode a Regexp object into JavaScript
  *
  * @param  Regexp $regexp
  * @return string
  */
 protected function encodeRegexp(Regexp $regexp)
 {
     return (string) $regexp->toJS();
 }
示例#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());
 }
示例#4
0
 protected function encodeRegexp(Regexp $regexp)
 {
     return $regexp->getJS();
 }