-
January 6th, 2008, 06:27 PM
#1
RegularExpressionValidator
Hi there.
I want to allow the user to select any but a couple of items in a listbox. I've got a RegularExpressionValidator for the listbox but I'm somewhat stuck on the regular expression - how do I say NOT string a or b?
"^(a|b)$" is exactly wrong but I don't seem to be able to say NOT "^(a|b)$" ... any clues???
Thanks for your time,
T
Some cause happiness wherever they go; others, whenever they go.
-
January 7th, 2008, 04:56 AM
#2
Re: RegularExpressionValidator
If you need to match any one-character string , except "A" AND "B", try
If you need to match any string not containing the letters 'A' or 'B', try
Or if you need to match any string not beginning with the letter 'A' or 'B':
- petter
-
January 7th, 2008, 05:26 AM
#3
Re: RegularExpressionValidator
Thanks for the reply. I'm trying to match a string, rather than character set - for example NOT ("Apples" OR "Pears"):
NOT (and that's the bit I'm having trouble with) "^(Apples|Pears)$".
Thanks again,
T
Some cause happiness wherever they go; others, whenever they go.
-
January 7th, 2008, 05:46 AM
#4
Re: RegularExpressionValidator
Ok, then you can use negative lookahead.
To match a string, except "Apples" or "Pears":
Code:
^(?!Apples$|Pears$).*$
Or, to match any string except thoes begginning with "Apples" or "Pears", try:
Code:
^(?!Apples|Pears).*$
- petter
-
January 7th, 2008, 05:29 PM
#5
Re: RegularExpressionValidator
That's exactly it - you're brilliant and amazing. I wasn't even on the right track! Regular expressions are indeed a world unto their own...
Thanks again,
T.
Some cause happiness wherever they go; others, whenever they go.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|