Hello all, could not find a regular expression forum, so I thought I would post it to my favorite of the forums.
I have a series of applications I've developed which all use a centralized function that creates a connection object and executes an SQL query, i.e. function Query().
I always sanitize my SQL statements to buffer all apostrophes with two apostrophes ala function Buffer().
However, I have long wondered if I could do away with Buffer(), and use a high-end regular expression to detect a string value in an SQL expression, and automatically replace any single apostrophes in the statement with doubles.
Psuedocode example:
I already have most of the logic done, but I am CRAP at regular expressions. Anyone think they've got the gusto to work with me on this one? I've tried a couple of times to write it myself, but keep giving up in frustration.
I have a series of applications I've developed which all use a centralized function that creates a connection object and executes an SQL query, i.e. function Query().
I always sanitize my SQL statements to buffer all apostrophes with two apostrophes ala function Buffer().
However, I have long wondered if I could do away with Buffer(), and use a high-end regular expression to detect a string value in an SQL expression, and automatically replace any single apostrophes in the statement with doubles.
Psuedocode example:
Code:
Query sSQL, rs .... (now inside [B]Query()[/B]) .. ' create connection, or use already open connection ' create new recordset ' regular expression analyzes SQL statement passed in thru arguments, detects the apostrophe in "o'toole" (but not the apostrophes surrounding "george o'toole") and VBScript replaces it with two apostrophes so that sSQL now looks like this: sSQL = "select id from users where name = 'george o''toole'" ' execute sql statement, return recordset to calling program
Comment