On Thu, 23 Jun 2005 13:13:04 -0700, baylor
<(E-Mail Removed)> wrote:
>How do i tell if a string obeys a regular expression?
>
>i thought i knew but then i tried to verify that a string was a certain
>length...
>
> Regex.IsMatch("1234", @"\w{1,3}")
>
>This returns true and i don't want it to!
>
>i understand that it found *a* match - "123" matched \w{3}. But i don't care
>if some substring matched, i want to know if the entire value matched
>
>Help?
>
>-baylor
If you want to match the whole string then put '^' at the start and
'$' at the end of your regular expression. They match
start-of-string/line and end-of-string/line respectively. Your
example would become @"^\w{1,3}$"
rossum
The ultimate truth is that there is no ultimate truth
|