Click to See Complete Forum and Search --> : stop regex command?


sublime1
December 5th, 2005, 09:39 PM
This forum seems like a great community :)

is there a way or perhaps some regex I can use to prevent a user from performing some regex on a main form?

pretty much the code I have does a regex on a "search" basis (word boundry etc..) so if a regex input has been inputted by the user then it may perform incorrect type searches - hard to explain!

basically - anyway I can stop a user inputting a regex command on input?

mmetzger
December 5th, 2005, 10:04 PM
I don't entirely understand the question, but the basics would involve looking for special characters in the string (slashes, commas, brackets, curly braces, parentheses, etc.)

sublime1
December 5th, 2005, 11:18 PM
thats right however is there a better way that I can go and compare each "illegal" character against each character as the input?

or even some other method?

mmetzger
December 6th, 2005, 08:40 AM
Not that I'm aware of but I'm still not entirely sure of the problem. The easiest way would be to have a regex match looking for the presence of regular expression characters. If present, don't perform the search. If they're not, then (if I'm guessing your meaning) use that string as part of a regex.

Depending on what you're doing, it may well be easier to use SQL or a DataTable.Select option and use SQL syntax instead.

sublime1
December 6th, 2005, 10:09 PM
unfortunatly SQL is not an option here
guess i have to make an array of "special" characters to look for and detect it....