122
rated 0 times
[
124]
[
2]
/ answers: 1 / hits: 44239
/ 15 Years ago, tue, july 14, 2009, 12:00:00
Try as I might, I can't get a RegEx to exclude space or single quotes.
- The string abc is allowed
- Not allowed: a'bc, ', 'abc, ''', abc'' etc
- Spaces could replace the ' too in the above example
- Trailing and leading spaces are assumed to be removed already
- Empty strings are checked elsewhere
- Target language is javascript
I'd use PATINDEX if I was in SQL.
Or NOT a positive match on either space or single quote, if I could negate...
I've tried (for single quote only)
w*[^']w*
^w*[^']w*$
- others I forget now
Please put me out of my misery so I can sleep tonight.
Edit:
- Target string will not be surrounded by Quotes. I thought thy might add clarity
- If Target language is javascript is wrong, then it's c#. I'd have to check where we do the validation exactly: client javascript or server c#
More From » regex