JavaScript and replace convert all SQL parameters (with colons) into data using regular expressions at a time. The specific implementation ideas and code are as follows. If you are interested, refer to the following, I hope to help you with the SQL parameter format, for example: select * from tb where nd =: nd and yd =: yd
To replace all parameters (with colons) in all SQL statements with data at one time,
Start
Select a regular expression.
Originally written like this
Strsql. replace (/(: \ w +)/g, ("$1"). substring (1 ));
"$1" is always parsed as a string instead of a matching value.
Change
Strsql. replace (/(: \ w +)/g, $1 );
No matching value is provided. To get a matching value, $1 must contain double quotation marks.
Then a method was added to the whimsy.
Pass $1 as a parameter, as shown below
Var strsql = strsql. replace (/(: \ w +)/g, function ($1) {var B = $1; return $ ("#" + B. substring (1 )). val ();});
For more articles about replacing all SQL parameters in the specified format with regular expressions in JS and replace, please refer to PHP!