$ in RegExp means the end of a string. So if the ValidationExpression
for a RegularExpressionValidator which validates a TextBox is "c
$" (without the double quotes), shouldn't input strings 'abc', '23pc',
'c9mccc' (all without the single quotes) evaluate to True BUT it
doesn't. In fact, these strings evaluate to False. Only the string
'c' (again without the single quotes) evaluates to True.
If I am not mistaken, "c$" means that any string (irrespective of its
length) will evaluate to True provided the last character in the
string is 'c' (without the single quotes). Or have I got it wrong? If
so, please correct me.
Thanks,
Ron
David Wier - 27 Mar 2008 21:14 GMT
I don't use them very often, but I thought it was the other way around - -
$c
David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
>$ in RegExp means the end of a string. So if the ValidationExpression
> for a RegularExpressionValidator which validates a TextBox is "c
[quoted text clipped - 11 lines]
>
> Ron
Nanda Lella[MSFT] - 27 Mar 2008 21:24 GMT
Hi Ron,
c$ means on 'c' and nothing else in the word.
If you are looking for any combination with a 'c', try something like
"^.*c.*$" (Without quotes)
"." represents any character. ^ = Start of the word, $ = end of the word.
You can also try removing the "^" from the above expression.
--------------------
>From: RN1 <rn5a@rediffmail.com>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
[quoted text clipped - 3 lines]
>Lines: 15
>Message-ID:
<f82aaa7f-ff2d-49b4-9ab0-698846bc959b@t54g2000hsg.googlegroups.com>
>NNTP-Posting-Host: 210.214.14.33
>Mime-Version: 1.0
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 7bit
>X-Trace: posting.google.com 1206648076 16849 127.0.0.1 (27 Mar 2008
20:01:16 GMT)
>X-Complaints-To: groups-abuse@google.com
>NNTP-Posting-Date: Thu, 27 Mar 2008 20:01:16 +0000 (UTC)
[quoted text clipped - 4 lines]
>X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
> Embedded Web Browser from: http://bsalsa.com/; .NET CLR 2.0.50727; .NET
CLR
> 3.0.04506.30; COM+ 1.0.2204),gzip(gfe),gzip(gfe)
>Path:
TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTFEEDS02.phx.gbl!msrtrans!
msrn-in!newshub.sdsu.edu!postnews.google.com!t54g2000hsg.googlegroups.com!no
t-for-mail
>Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:63081
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
[quoted text clipped - 14 lines]
>
>Ron

Signature
Thank You,
Nanda Lella,
This Posting is provided "AS IS" with no warranties, and confers no rights.
Mick Wilson - 27 Mar 2008 21:37 GMT
Try this site for help:
http://www.nregex.com/nregex/default.aspx
It gives some explanation on what the various characters mean as well
as a good tool to use for building a regular expression.
If you want any string ending in 'c', use ^.*c$
RN1 - 27 Mar 2008 22:35 GMT
> Try this site for help:
>
[quoted text clipped - 4 lines]
>
> If you want any string ending in 'c', use ^.*c$
Thanks, my dear friends, for your inputs. I knew that "c$" would allow
only "c" & nothing else (i.e. the length of the string can be 1 & 1
only, not more than that) but in the article at
http://www.regular-expressions.info/anchors.html, it is stated that
-----------------------------------------
c$ matches c in abc
-----------------------------------------
(which is the 11th line in that article considering that the line
after the heading "Start of String and End of String Anchors" is the
1st line). Isn't that statement wrong? Yes...."c$" matches "c" in the
string "abc" but the string "abc" evaluates to False when the RegEx is
"c$". Or have I misinterpreted the term "matches" used in that
article?
That is what confused me.....
Ron
Stan - 27 Mar 2008 22:20 GMT
> $ in RegExp means the end of a string. So if the ValidationExpression
> for a RegularExpressionValidator which validates a TextBox is "c
[quoted text clipped - 11 lines]
>
> Ron
I believe the correct syntax for your requirement will be \w+[c]
You will also need a RequiredFieldValidator to prevent empty strings
from bypassing the expression evaluator.
BTW I don't know about the $ it doesn't feature in the RegExp
documentation that I've seen.
bruce barker - 28 Mar 2008 02:10 GMT
in a regular expression c$ will match abc (the capture will be c), but will
not with the RegularExpressionValidator. the RegularExpressionValidator
compares the controls value to the match, so it is the same as if your
expression was:
^c$$
to just check for an ending c with the RegularExpressionValidator you would
use:
.*c
which will be treated like
^.*c$
-- bruce (sqlwork.com)
> $ in RegExp means the end of a string. So if the ValidationExpression
> for a RegularExpressionValidator which validates a TextBox is "c
[quoted text clipped - 11 lines]
>
> Ron
Jesse Houwing - 31 Mar 2008 19:48 GMT
Hello RN1,
> $ in RegExp means the end of a string. So if the ValidationExpression
> for a RegularExpressionValidator which validates a TextBox is "c
[quoted text clipped - 6 lines]
> string is 'c' (without the single quotes). Or have I got it wrong? If
> so, please correct me.
Your regex is completely correct, just so you know, but there is a little
undocumented feature in the RagularExpressionValidator that puts a ^ and
a $ around the expression regardless of your wishes. os it actually tries
to evaluate this:
^c$$, which only accepts c as input.
The correct solution would be to make it
.*c
or
^.*c$
which will evaluate correctly.
--
Jesse Houwing
jesse.houwing at sogeti.nl