C
carlos
I am working on a regular expression validation for my search page.
What I have so far works for most cases, but I would like to fine tune
it some. I am new to regular expressions, and I do not have the time
to read up some more on it. Can someone help?
What I would like to do is allow words to be parsed using quotes.
However, they can also include boolean searching. Lastly, I need to
ensure the character's do not exceed a certain length. The expression
I have works, but if I put quotes on the first and not on the second
it should fail, but it is passing?? See below
Regex regex = new Regex("(?i)" + "(?:" + "\\" + "s*OR" + "\\" +
"s*)?" + "\"" + "([^" + "\"" + "]*)" + "\"");
passed = regex.IsMatch(value);
How the strings should pass:
"test" "this" "search"
"test" OR "this"
"this" AND "that"
This is passing, but should fail
"test" akfjafkajfakfj
Any suggestions?
What I have so far works for most cases, but I would like to fine tune
it some. I am new to regular expressions, and I do not have the time
to read up some more on it. Can someone help?
What I would like to do is allow words to be parsed using quotes.
However, they can also include boolean searching. Lastly, I need to
ensure the character's do not exceed a certain length. The expression
I have works, but if I put quotes on the first and not on the second
it should fail, but it is passing?? See below
Regex regex = new Regex("(?i)" + "(?:" + "\\" + "s*OR" + "\\" +
"s*)?" + "\"" + "([^" + "\"" + "]*)" + "\"");
passed = regex.IsMatch(value);
How the strings should pass:
"test" "this" "search"
"test" OR "this"
"this" AND "that"
This is passing, but should fail
"test" akfjafkajfakfj
Any suggestions?