From: icccapital on
I am trying to create a regular expression for matching dates. After finding
that my regex pattern didn't work I decided to pare it down and see if I
could figure out why. Now I can't get the test to just match a single
character and reject multiple characters.

So in my test I have myRegex.pattern = "[0-9]" and myRegex.test("15"), if I
am not mistaken that regular expression should just match 1 digit right? But
15 returns true because it finds at least 1 of the digits that matches.

Am I doing something wrong? thanks.
From: Tom Shelton on
icccapital laid this down on his screen :
> I am trying to create a regular expression for matching dates. After finding
> that my regex pattern didn't work I decided to pare it down and see if I
> could figure out why. Now I can't get the test to just match a single
> character and reject multiple characters.
>
> So in my test I have myRegex.pattern = "[0-9]" and myRegex.test("15"), if I
> am not mistaken that regular expression should just match 1 digit right? But
> 15 returns true because it finds at least 1 of the digits that matches.
>
> Am I doing something wrong? thanks.

^/d{1,1}$

--
Tom Shelton


From: Jeff Johnson on
"icccapital" <icccapital(a)discussions.microsoft.com> wrote in message
news:20427EA5-D100-458D-8169-90EB43F6374F(a)microsoft.com...

>I am trying to create a regular expression for matching dates. After
>finding
> that my regex pattern didn't work I decided to pare it down and see if I
> could figure out why. Now I can't get the test to just match a single
> character and reject multiple characters.
>
> So in my test I have myRegex.pattern = "[0-9]" and myRegex.test("15"), if
> I
> am not mistaken that regular expression should just match 1 digit right?
> But
> 15 returns true because it finds at least 1 of the digits that matches.
>
> Am I doing something wrong? thanks.

I would think that you'd get two matches, the 1 and the 5. Perhaps it was
the way you were accessing the matches that returned the full number. But
since you didn't post any code....


From: Tom Shelton on
icccapital was thinking very hard :
> Thanks Tom, forgot the ^ and $. That was helpful
>

Cool... Also, you can drop the quantifier :) I don't know why I put
that in. Rusty, I guess :)

^/d$

--
Tom Shelton


From: Jeff Johnson on
"Tom Shelton" <tom_shelton(a)comcast.invalid> wrote in message
news:i2kjvr$oha$1(a)news.eternal-september.org...

> Cool... Also, you can drop the quantifier :) I don't know why I put that
> in. Rusty, I guess :)
>
> ^/d$

HAHAHAHAHAHA!!! Look at the slash....