Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
regexfield.php
1
<?php
2
3
namespace
Bitrix\Main\PhoneNumber\Tools
;
4
5
use
Bitrix\Main\SystemException
;
6
7
class
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
}
Bitrix\Main\PhoneNumber\Tools\RegexField
Definition
regexfield.php:8
Bitrix\Main\PhoneNumber\Tools\RegexField\validateRegex
static validateRegex($regex, $removeWhitespace=false)
Definition
regexfield.php:14
Bitrix\Main\PhoneNumber\Tools\RegexField\decodeValue
decodeValue($value)
Definition
regexfield.php:9
Bitrix\Main\PhoneNumber\Tools\XmlField
Definition
xmlfield.php:6
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Main\PhoneNumber\Tools
Definition
boolfield.php:3
modules
main
lib
phonenumber
tools
regexfield.php
Создано системой
1.10.0