Re: RegExp DoubleQuote
- From: "Jennifer Mathews" <waltersjennifer@xxxxxxxx>
- Date: Mon, 26 Oct 2009 09:28:35 -0400
Thanks very much Jesse.
I played with it for days (and hour here & and hour there) and it was either not working properly or I was receiving errors as I made changes as you suggested. I just stopped looking at it in frustration and left it without the double quotes. To make a long story short, I just went back to it and realized "not working properly" was because in the code I had left out for the allowance of <SPACE> in the """ edition. It had nothing to do with the """. <grrrrr>
It now works great and even though it was an old post, I just wanted to say thanks.
"Jesse Houwing" <jesse.houwing@xxxxxxxxxxxxxxxx> wrote in message news:4AD659F2.5080808@xxxxxxxxxxxxxxxxxxx
* Jennifer Mathews wrote, On 14-10-2009 21:17:ValidationExpression="[?&\-\[\]\{\}\\#/><$%!@()':;,._+=0-9a-zA-Z"]+"></asp:RegularExpressionValidator>
WOW!!! Got it to work! Thanks,
But another problem came-up with the following:
ValidationExpression="[?&\-\[\]\{\}\\#/><$%!@()':;,._+=0-9a-zA-Z"]+{3,50}"
/>
When I put {3,50} for the min and max length, I got the following error:
"parsing "[?&\-\[\]\{\}\\#/><$%!@()':;,._+=0-9a-zA-Z"]+{3,50}" - Nested
quantifier {. "
And length does matter. :)
You've got a +{3,50} in there.
Remove the + and it should start working again.
Jesse
"Jesse Houwing" <jesse.houwing@xxxxxxxxxxxxxxxx> wrote in message
news:eDvJ7jsRKHA.4116@xxxxxxxxxxxxxxxxxxxxxxx
* Jennifer Mathews wrote, On 6-10-2009 8:50:Ohhhh ... thanks for the explaination. I thought you were saying
something else.
I just tried your explaination on
ValidationExpression=""[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=
0-9a-zA-Z]+""
and recieved an error that the quotes don't match.
try:
ValidationExpression="[?&\-\[\]\{\}\\#/><$%!@()':;,._+=0-9a-zA-Z"]+"
As in the sample code below. I tried running it and it works. Notice
that you officially need to escape the < and the > as well when you
put them in a tag.
<asp:RegularExpressionValidator ID="ReularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"
ValidationExpression="[?&\-\[\]\{\}\\#/><$%!@()':;,._+=0-9a-zA-Z"]+"></asp:RegularExpressionValidator>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
I ran it on my local machine and it works.
Notice that the sample expression I posted earlier doesn't match your
requirements, but did show you how to add " to the
ValidationExpression. The place you added it, doesn't make sense in
regards to your previous requirements.
As to why you need to escape the " in this fashion. Any HTML attribute
needs to be escaped according to the rules of the HTML specs. And they
say that when embedding special characters (like ", <, >) in an
attribute, that you need to escape them.
On top of that, you also need to escape certain characters because
they have a special meaning in Regex. Just as you'd have to escape
them doubly when you put them in source, eg:
ReularExpressionValidator1.ValidationExpression =
"[?&\\-\\[\\]\\{\\}\\\\#/<>$%!@()':;,._+=0-9a-zA-Z\"]+";
Or
ReularExpressionValidator1.ValidationExpression =
@"[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=0-9a-zA-Z""]+";
Every method has it's own rules.
Jesse
"Jesse Houwing" <jesse.houwing@xxxxxxxxxxxxxxxx> wrote in message
news:O5O8fmdRKHA.4504@xxxxxxxxxxxxxxxxxxxxxxx
* Jennifer Mathews wrote, On 5-10-2009 15:38:Unfortunately that won't work because it is a regular expression.
Have you actually tried it? If you edit the expression from the
designer it generates " in the expression.
See the following generated code:
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"
ValidationExpression=""[abab]+""></asp:RegularExpressionValidator>
"Jesse Houwing" <jesse.houwing@xxxxxxxxxxxxxxxx> wrote in message
news:e132TrTRKHA.4580@xxxxxxxxxxxxxxxxxxxxxxx
* Jeff Johnson wrote, On 4-10-2009 7:16:"Jennifer Mathews"<waltersjennifer@xxxxxxxx> wrote in message
news:701CCF18-0530-479A-9D15-CA857FB7509B@xxxxxxxxxxxxxxxx
I have a regular expression:
ValidationExpression="[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=
0-9a-zA-Z]{2,60}"
which contains all the characters we need
except DOUBLEQUOTE.
I have tried putting \" (backslash doublequote) into it but that
does
not work and I recieve an error about it being malformed.
"Malformed"? Are you doing this on an ASPX page by any chance? I ask
because
I just ran into this problem myself, and it's due to the fact that
ASP.NET
can't handle quotes nested within quotes. I had to create a property
in the
code-behind which did nothing more than return a quote and then
concatenate
it into my target string.
Have you tried " to put in the quotes? That's how they should be
escaped in an HTML tag. I haven't tried this myself in an actual ASPX
page, but it might work.
Jesse
--
Jesse Houwing
jesse.houwing at sogeti.nl
--
Jesse Houwing
jesse.houwing at sogeti.nl
--
Jesse Houwing
jesse.houwing at sogeti.nl
--
Jesse Houwing
jesse.houwing at sogeti.nl
.
- Follow-Ups:
- Re: RegExp DoubleQuote
- From: Jesse Houwing
- Re: RegExp DoubleQuote
- References:
- RegExp DoubleQuote
- From: Jennifer Mathews
- Re: RegExp DoubleQuote
- From: Jeff Johnson
- Re: RegExp DoubleQuote
- From: Jesse Houwing
- Re: RegExp DoubleQuote
- From: Jennifer Mathews
- Re: RegExp DoubleQuote
- From: Jesse Houwing
- Re: RegExp DoubleQuote
- From: Jennifer Mathews
- Re: RegExp DoubleQuote
- From: Jesse Houwing
- Re: RegExp DoubleQuote
- From: Jennifer Mathews
- Re: RegExp DoubleQuote
- From: Jesse Houwing
- RegExp DoubleQuote
- Prev by Date: Re: How do you access public and protected variables in the same test?
- Next by Date: Re: How do you access public and protected variables in the same test?
- Previous by thread: Re: RegExp DoubleQuote
- Next by thread: Re: RegExp DoubleQuote
- Index(es):
Relevant Pages
|