Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
regexfield.php
1<?php
2
4
6
7class RegexField extends XmlField
8{
9 public function decodeValue($value)
10 {
11 return static::validateRegex($value, true);
12 }
13
14 public static function validateRegex($regex, $removeWhitespace = false)
15 {
16 $compressedRegex = $removeWhitespace ? preg_replace('/\\s/', '', $regex) : $regex;
17
18 // Match regex against an empty string to check the regex is valid
19 if (preg_match('/'.$compressedRegex.'/', '') === false)
20 {
21 throw new SystemException("Regex error: ".preg_last_error());
22 }
23
24 return $compressedRegex;
25 }
26
27}
static validateRegex($regex, $removeWhitespace=false)