1 | <?php |
||
4 | trait PatternTrait |
||
5 | { |
||
6 | use XMLPatterns; |
||
7 | /** |
||
8 | * @Exclude |
||
9 | * @var array defines the exact sequence of characters that are acceptable |
||
10 | */ |
||
11 | private $pattern = array(); |
||
12 | |||
13 | /** |
||
14 | * @param string $newPatternToAdd |
||
15 | * @param mixed $processMultiCharacterEscape |
||
16 | */ |
||
17 | protected function setPatternFacet($newPatternToAdd, $processMultiCharacterEscape = true) |
||
31 | |||
32 | /** |
||
33 | * @param string $patternToProcess |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | private function processRegex($patternToProcess, $processMultiCharacterEscape) |
||
38 | { |
||
39 | if (!$processMultiCharacterEscape) { |
||
40 | return $patternToProcess; |
||
41 | } |
||
42 | if (null == self::$NameChar) { |
||
43 | init(); |
||
44 | } |
||
45 | |||
46 | $patternToProcess = str_replace('\S', '[^\s]', $patternToProcess); |
||
47 | $patternToProcess = str_replace('\s', '[\x{20}\t\n\r]', $patternToProcess); |
||
48 | $patternToProcess = str_replace('\I', '[^\i]', $patternToProcess); |
||
49 | $patternToProcess = str_replace('\i', self::$Letter . '|_|:', $patternToProcess); |
||
50 | $patternToProcess = str_replace('\c', self::$NameChar, $patternToProcess); |
||
51 | $patternToProcess = str_replace('\D', '[^\d]', $patternToProcess); |
||
52 | $patternToProcess = str_replace('\d', '\p{Nd}', $patternToProcess); |
||
53 | $patternToProcess = str_replace('\W', '[^\w]', $patternToProcess); |
||
54 | $patternToProcess = str_replace('\w', '[\x{0000}-\x{10FFFF}]-[\p{P}\p{Z}\p{C}] ', $patternToProcess); |
||
55 | return $patternToProcess; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param string $pattern |
||
60 | */ |
||
61 | private function checkRegexValidPattern($pattern) |
||
65 | |||
66 | /** |
||
67 | * @param string $v |
||
68 | */ |
||
69 | private function checkPattern($v) |
||
80 | |||
81 | /** |
||
82 | * Checks a pattern against a string. |
||
83 | * |
||
84 | * @param string $pattern the regex pattern |
||
85 | * @param string $string the string to check |
||
86 | * @return bool true if string matches pattern |
||
87 | */ |
||
88 | private function matchesRegexPattern($pattern, $string) |
||
93 | } |
||
94 |