Escaping for regex search
Beatrix Willius
bwillius at gmx.de
Sun May 27 02:43:04 CDT 2012
My search uses regex searching. What's the best way for escaping the standard regex characters like "+" so that it doesn't interfere with Valentina escaping?
Can anyone tell me what is escaped with Valentina.escapestring? This is not mentioned at http://www.valentina-db.com/dokuwiki/doku.php?id=valentina:vcomponents:vkernel:vfield:string_fields .
I think most characters should be okay. But what about [ and ]?
My own regex escape looks like the following:
theResult = ReplaceAll(theResult, "\", "\\")
theResult = ReplaceAll(theResult, ".", "\.")
theResult = ReplaceAll(theResult, "[", "\[")
theResult = ReplaceAll(theResult, "]", "\]")
theResult = ReplaceAll(theResult, "|", "\|")
theResult = ReplaceAll(theResult, "{", "\{")
theResult = ReplaceAll(theResult, "}", "\}")
theResult = ReplaceAll(theResult, "(", "\(")
theResult = ReplaceAll(theResult, ")", "\)")
theResult = ReplaceAll(theResult, " ", "\ ")
theResult = ReplaceAll(theResult, "^", "\^")
theResult = ReplaceAll(theResult, "?", "\?")
theResult = ReplaceAll(theResult, "*", "\*")
theResult = ReplaceAll(theResult, "+", "\+")
theResult = ReplaceAll(theResult, "$", "\$")
theResult = ReplaceAll(theResult, "&", "\&")
theResult = ReplaceAll(theResult, "'", "\'")
theResult = ReplaceAll(theResult, "`", "\`")
Wouldn't the easiest solution be an additional Valentina.EscapeStringRegex? This would escape for both sql AND regex at the same time.
Mit freundlichen Grüßen/Regards
Trixi Willius
http://www.mothsoftware.com
Mail Archiver X: The email archiving solution for professionals
More information about the Valentina
mailing list