RegExp DoubleQuote

  • Thread starter Jennifer Mathews
  • Start date
J

Jennifer Mathews

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.

So how do I put the doublequote into it?

Thanks
 
P

Peter Duniho

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.

So how do I put the doublequote into it?

If I recall correctly, the double-quote is meaningful to Regex. If so,
you need to quote both the double-quote and the backslash: \\\"

Pete
 
J

Jeff Johnson

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.
 
J

Jennifer Mathews

Yes. I am doing it on an ASPX page.

Can you show me what you are doing? I am having the same
problem with a SingleQuote. The SingleQuote isn't generating
an error, but it is just being ignored as a valid character and this
is driving the users crazy.

For SingleQuotes, I have tried both:
' <<<< just the singlequote mark
\' <<<< escaped with the singlequote mark

Thanks

Jeff Johnson said:
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.
 
J

Jesse Houwing

* Jeff Johnson wrote, On 4-10-2009 7:16:
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 &quot; 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
 
J

Jennifer Mathews

Unfortunately that won't work because it is a regular expression.

Jesse Houwing said:
* Jeff Johnson wrote, On 4-10-2009 7:16:
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 &quot; 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
 
J

Jesse Houwing

* 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 &quot; in the expression.

See the following generated code:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1"
ErrorMessage="RegularExpressionValidator"

Jesse Houwing said:
* Jeff Johnson wrote, On 4-10-2009 7:16:
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 &quot; 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
 
J

Jennifer Mathews

Ohhhh ... thanks for the explaination. I thought you were saying something else.

I just tried your explaination on

ValidationExpression="&quot;[?&\-\[\]\{\}\\#/<>$%!@()':;,._+= 0-9a-zA-Z]+&quot;"

and recieved an error that the quotes don't match.


Jesse Houwing said:
* 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
&quot; in the expression.

See the following generated code:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"

Jesse Houwing said:
* Jeff Johnson wrote, On 4-10-2009 7:16:

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 &quot; 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
 
J

Jennifer Mathews

During the displaying of the web page to the user, it generates an error of "The server
tag is not well formed."
Notice the \\\" in the first few characters. Any other ideas?

ValidationExpression="[\\\"?&\-\[\]\{\}\\#/<>$%!@()':;,._+= 0-9a-zA-Z]{5,230}"


Peter Duniho said:
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.

So how do I put the doublequote into it?

If I recall correctly, the double-quote is meaningful to Regex. If so, you need to
quote both the double-quote and the backslash: \\\"

Pete
 
J

Jeff Johnson

Yes. I am doing it on an ASPX page.

Can you show me what you are doing? I am having the same
problem with a SingleQuote. The SingleQuote isn't generating
an error, but it is just being ignored as a valid character and this
is driving the users crazy.

In the code-behind:

public string Quote
{
get { return "\""; }
}

In the markup:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"
ValidationExpression="<%= Quote + "[abab]+" + Quote
%>"></asp:RegularExpressionValidator>
 
J

Jennifer Mathews

Thanks. I will try that.

Jeff Johnson said:
Yes. I am doing it on an ASPX page.

Can you show me what you are doing? I am having the same
problem with a SingleQuote. The SingleQuote isn't generating
an error, but it is just being ignored as a valid character and this
is driving the users crazy.

In the code-behind:

public string Quote
{
get { return "\""; }
}

In the markup:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"
ValidationExpression="<%= Quote + "[abab]+" + Quote
%>"></asp:RegularExpressionValidator>
 
J

Jesse Houwing

* 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="&quot;[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=
0-9a-zA-Z]+&quot;"

and recieved an error that the quotes don't match.

try:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"

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="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></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 &quot; 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 said:
* 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 &quot; in the expression.

See the following generated code:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"

ValidationExpression="&quot;[abab]+&quot;"></asp:RegularExpressionValidator>


* Jeff Johnson wrote, On 4-10-2009 7:16:

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 &quot; 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
 
J

Jennifer Mathews

You guys answer faster than I can test everything.

Thanks very much to everyone. I will try this too and let everyone know.

Jesse Houwing said:
* 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="&quot;[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=
0-9a-zA-Z]+&quot;"

and recieved an error that the quotes don't match.

try:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"

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="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></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 &quot; 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 said:
* 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 &quot; in the expression.

See the following generated code:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"

ValidationExpression="&quot;[abab]+&quot;"></asp:RegularExpressionValidator>




* Jeff Johnson wrote, On 4-10-2009 7:16:

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 &quot; 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
 
J

Jennifer Mathews

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></asp:RegularExpressionValidator>

WOW!!! Got it to work! Thanks,

But another problem came-up with the following:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+{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. :)


Jesse Houwing said:
* 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="&quot;[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=
0-9a-zA-Z]+&quot;"

and recieved an error that the quotes don't match.

try:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"

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="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></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 &quot; 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 said:
* 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 &quot; in the expression.

See the following generated code:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"

ValidationExpression="&quot;[abab]+&quot;"></asp:RegularExpressionValidator>




* Jeff Johnson wrote, On 4-10-2009 7:16:

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 &quot; 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
 
J

Jennifer Mathews

I did come-up with a jQuery solution that is to slow. The one thing I have found is
that although jQuery provides a wealth of search capabilities, it is exceedingly slow.

"rev_txt_MB_Master_Subject_Name" is the name of the validation control.

$('[id *= rev_txt_MB_Master_Subject_Name]').each(function() {
var xxx = this;
xxx.validationexpression = "[?&\\-#$%\\'()\":;,._ 0-9a-zA-Z]{3,50}";
})


Jesse Houwing said:
* 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="&quot;[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=
0-9a-zA-Z]+&quot;"

and recieved an error that the quotes don't match.

try:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"

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="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></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 &quot; 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 said:
* 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 &quot; in the expression.

See the following generated code:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"

ValidationExpression="&quot;[abab]+&quot;"></asp:RegularExpressionValidator>




* Jeff Johnson wrote, On 4-10-2009 7:16:

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 &quot; 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
 
J

Jesse Houwing

* Jennifer Mathews wrote, On 14-10-2009 21:17:
ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></asp:RegularExpressionValidator>

WOW!!! Got it to work! Thanks,

But another problem came-up with the following:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+{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 said:
* 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="&quot;[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=
0-9a-zA-Z]+&quot;"

and recieved an error that the quotes don't match.

try:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"


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="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></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 &quot; 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

* 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 &quot; in the expression.

See the following generated code:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"

ValidationExpression="&quot;[abab]+&quot;"></asp:RegularExpressionValidator>





* Jeff Johnson wrote, On 4-10-2009 7:16:

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 &quot; 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
 
J

Jennifer Mathews

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 "&quot" edition. It had
nothing to do with the "&quot". <grrrrr>

It now works great and even though it was an old post, I just wanted to say thanks.


Jesse Houwing said:
* Jennifer Mathews wrote, On 14-10-2009 21:17:
ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></asp:RegularExpressionValidator>

WOW!!! Got it to work! Thanks,

But another problem came-up with the following:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+{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 said:
* 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="&quot;[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=
0-9a-zA-Z]+&quot;"

and recieved an error that the quotes don't match.

try:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"


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="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></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 &quot; 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




* 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 &quot; in the expression.

See the following generated code:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"

ValidationExpression="&quot;[abab]+&quot;"></asp:RegularExpressionValidator>





* Jeff Johnson wrote, On 4-10-2009 7:16:

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 &quot; 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
 
J

Jesse Houwing

* Jennifer Mathews wrote, On 26-10-2009 14:28:
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 "&quot" edition. It had
nothing to do with the "&quot". <grrrrr>

It now works great and even though it was an old post, I just wanted to
say thanks

You're very welcome :)

Jesse

Jesse Houwing said:
* Jennifer Mathews wrote, On 14-10-2009 21:17:
ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></asp:RegularExpressionValidator>



WOW!!! Got it to work! Thanks,

But another problem came-up with the following:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+{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
* 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="&quot;[?&\-\[\]\{\}\\#/<>$%!@()':;,._+=
0-9a-zA-Z]+&quot;"

and recieved an error that the quotes don't match.

try:

ValidationExpression="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"



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="[?&\-\[\]\{\}\\#/&gt;&lt;$%!@()':;,._+=0-9a-zA-Z&quot;]+"></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 &quot; 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




* 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 &quot; in the expression.

See the following generated code:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox1"
ErrorMessage="RegularExpressionValidator"

ValidationExpression="&quot;[abab]+&quot;"></asp:RegularExpressionValidator>






* Jeff Johnson wrote, On 4-10-2009 7:16:

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 &quot; 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top