jcs:regex() Function

Syntax

var $result = jcs:regex(pattern, string)

Description

Evaluate a regular expression against a given string argument and return any matches. This function requires two arguments: the regular expression and the string within which to search for the expression.

Parameters

Return Value

var $pattern = "([0-9]+)(:*)([a-z]*)";
var $a = jcs:regex($pattern, "123:xyz");
var $b = jcs:regex($pattern, "r2d2");
var $c = jcs:regex($pattern, "test999!!!");
 
$a[1] == "123:xyz" # string that matches the full reg expression
$a[2] == "123" # ([0-9]+)
$a[3] == ":" # (:*)
$a[4] == "xyz" # ([a-z]*)
$b[1] == "2d" # string that matches the full reg expression
$b[2] == "2" # ([0-9]+)
$b[3] == "" # (:*) [empty match]
$b[4] == "d" # ([a-z]*)
$c[1] == "999" # string that matches the full reg expression
$c[2] == "999" # ([0-9]+)
$c[3] == "" # (:*) [empty match]
$c[4] == "" # ([a-z]*) [empty match]