The Regex
policy class let you implement text data validation based on static templates (regular expressions).
A PSL description of the Regex
class is provided in the following file:
/opt/KasperskyOS-Community-Edition-<version>/toolchain/include/nk/regex.psl
Regex class object
A Regex
class object is automatically created when connecting the PSL description of the class.
You may need to create additional objects of the Regex
class to declare audit profiles associated with these objects.
Regex
class objects do not have configurations.
Regex class policies
The Regex
policy class consists of the following expression policies:
match {text: Text, pattern: Pattern}
Takes the Text
string and Pattern
regular expression. Returns a Boolean
type value: True
if match, otherwise False.
Example: assert (re.match {text: message.text, pattern: "^[0-9]*$"})
select {text: Text}
Accepts a string. Intended for use with the choice
operator to check for matches with multiple regular expressions.
Example:
choice (re.select {text: "hello world"}) {
"^hello .*": grant ()
".*world$" : grant ()
_ : deny ()
}