Contents - Index


RegExSub (function)

RegExSub(sExpression, sData, nMatch, nSubExpression) : string

sExpression - The regular expression to match
sData - The string to search for this regular expression
nMatch - The Nth match of your sExpression
nSubExpression - The sub expression number to retrieve

Regular expressions can contain sub expressions (anything in parenthesis). This function gives you the ability to interrogate the matching sub expression as opposed to the whole matched expression. For example:

$data = "I found only 99 dalmatians instead of the expected 101 dalmatians"
$regex = "(\d*) dalmatians"

Expression                       Result

RegExCount($regex,$data)          2
RegExData($regex,$data,1)         99 dalmatians
RegexData($regex,$data,2)         101 dalmatians
RegExSub($regex,$data,1,1)        99
RegExSub($regex,$data,2,1)        101

Alpha List         Category List