Open GoogleCodeExporter opened 8 years ago
actually debugged this issue on the Try It Yourself editor for match()
http://www.w3schools.com/jsref/jsref_match_regexp.asp
Original comment by kucerari...@gmail.com
on 9 Oct 2009 at 3:30
fixed an issue with allowable characters for keyword searches.
on your input boxes way up at the front end, please filter, it is the best
place to
do it:
keywords[i] = keywords[i].replace(/[^a-zA-Z0-9 %^$.]/g, '.');
That regex needs to work in conjunction with the regex in trimpath core, this
is a
best compromise for keywords as far as I know. Added '.' in order to replace
unacceptable characters with single wildcard. In practice I think this is
acceptable:
var js = this.sql;
js = js.replace(/ AND /g, " && ");
js = js.replace(/ OR /g, " || ");
js = js.replace(/ = /g, " == ");
js = js.replace(/ IS NULL/g, " == null");
js = js.replace(/ IS NOT NULL/g, " != null");
js = js.replace(/ NOT /g, " ! ");
var LIKE_regex = /(\S+)\sLIKE\s'([a-zA-Z0-9 %^$.]+)'/g;
var LIKE_regex_incr = /(\S+)\sLIKE\s'([a-zA-Z0-9 %^$.]+)'/;
var matchArr;
while(matchArr = LIKE_regex.exec(js) ) {
matchArr[2] = matchArr[2].replace(/%/, '.*');
js = js.replace(LIKE_regex_incr, "$1.match(/"+matchArr[2]+"/i)");
}
There are new attachments with this code.
Original comment by kucerari...@gmail.com
on 13 Oct 2009 at 3:02
Attachments:
Original issue reported on code.google.com by
kucerari...@gmail.com
on 9 Oct 2009 at 3:28Attachments: