Re: The length of search

Oleg Sukhodolsky <[email protected]> Sun, 30 Nov 2003 19:09:23 +0300
Newsgroups gmane.comp.jakarta.regexp.user
Message-ID <[email protected]>
> Why:

> RE re = new RE([:alnum:]{3,8});
> re.match("123456789");

> .. returns true?

Because RE.match() try to find any substring which matches regexp.

> .. and is there any way to get false current situation?

> I need to make some security checks for form parameters, and
> i need to check that parameter contains 3-8 characters, and regexp
> seems quite handy for that.

> If thats not possible with regexp, how about ORO?? examples??

It's possible.  I think you should try "^[:alnum:]{3,8}$" (^ - start
of line, $ end of line, so you will get true only if whole string
matches regexp).

With best regards, Oleg.