TopLevel validateSqlRegexpPatternJSON.php - jcobban/Genealogy GitHub Wiki
This script provides the ability for the dynamic code of any web page to validate a regular expression for conformance to the implementation of the REGEXP operator in the SQL server. Not all SQL servers support regular expressions and those that do generally support the Extended Regular Expression (ERE) syntax, not the Perl-Compatible Regular Expression (PCRE) syntax supported by most programming languages.
The parameters are passed by method=get
are:
name | description |
---|---|
'expression' | regular expression to test |
The response looks like:
{
"parms" : {
"pattern" : "x(*)"
},
"query" : "SELECT Surname FROM tblNR WHERE Surname REGEXP 'x(*)'",
"msg":" result=Got error 'nothing to repeat at offset 2' from regexp, 42000, 1139"
}
This response is handled by JavaScript code. jsonobj.parms
contains an associative array containing all of the parameters passed to the script. This may include other parameters in addition to jsonobj.parms.pattern
. These extra parameters may be used, for example, to pass additional information to the server which is available to the response handler, for example the value of the id
attribute of the requesting field. jsonobj.query
contains the command issued to the server. If jsonobj.msg
is present the value contains three pieces of information from the SQL server. The text of the detailed explanation from the server is enclosed in apostrophes. The second last number is the error code from the ANSI standard for SQL. The last number is the implementation specific error code.
Next: Videos.js