You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Leonard Sitongia <si...@ucar.edu> on 2004/05/11 21:55:39 UTC

Validator mask boundary matchers don't work

I'm using Struts 1.1.  I have an html:text input field.

I'm trying to constrain the input field to be two strings separated by 
a space.

I have tried

             <var-value>\w\s\w</var-value>

but that allows two *or more* strings separated by spaces, such as "xxx 
yyy zzz".

I have tried using the boundary matchers, as in

             <var-value>^\w\s\w$</var-value>

Then no input works.  I thought I read that ^ and $ are required in 
1.1, but I can't get it to work with them.
It's not then expecting literal ^ and $, but I don't know what it's 
doing.

TIA.
==Leonard E. Sitongia
   VETS / Scientific Computing Division
   National Center for Atmospheric Research
   P.O. Box 3000 Boulder CO 80307  USA
   sitongia@ucar.edu    voice: (303)497-2454   fax: (303)497-1829


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Validator mask boundary matchers don't work

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
--> Since version 1.1, the regular expression must start with a ^ and
end with a $ (see example below).
(http://jakarta.apache.org/struts/userGuide/dev_validator.html)



> -----Original Message-----
> From: Leonard Sitongia [mailto:sitongia@ucar.edu] 
> Sent: Tuesday, May 11, 2004 10:55 PM
> To: Struts Users Mailing List
> Subject: Re: Validator mask boundary matchers don't work
> 
> 
> 
> On May 11, 2004, at 2:52 PM, Leonard Sitongia wrote:
> 
> >
> > On May 11, 2004, at 2:44 PM, Leonard Sitongia wrote:
> >
> >>
> >> I'll try your suggestion.
> >>
> > I tried \w+\s\w+ (plus instead of * in order to require at 
> least one),
> > and it still accepts more than two strings, e.g. "xxx yyy zzz"...
> >
> 
> This worked:
> 
> ^\w+\s\w+$
> 
> In other words, the boundary matchers work when I have the right 
> regexp.  :-)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validator mask boundary matchers don't work

Posted by Leonard Sitongia <si...@ucar.edu>.
On May 11, 2004, at 2:52 PM, Leonard Sitongia wrote:

>
> On May 11, 2004, at 2:44 PM, Leonard Sitongia wrote:
>
>>
>> I'll try your suggestion.
>>
> I tried \w+\s\w+ (plus instead of * in order to require at least one), 
> and it still accepts more than two strings, e.g. "xxx yyy zzz"...
>

This worked:

^\w+\s\w+$

In other words, the boundary matchers work when I have the right 
regexp.  :-)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validator mask boundary matchers don't work

Posted by Leonard Sitongia <si...@ucar.edu>.
On May 11, 2004, at 2:44 PM, Leonard Sitongia wrote:

>
> I'll try your suggestion.
>
I tried \w+\s\w+ (plus instead of * in order to require at least one), 
and it still accepts more than two strings, e.g. "xxx yyy zzz"...


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validator mask boundary matchers don't work

Posted by Leonard Sitongia <si...@ucar.edu>.
On May 11, 2004, at 2:39 PM, Robert McBride wrote:

>
> That regualar expression will only match exactly one word character 
> then one whitespace character
> then another word character. (A word character is in the set of 
> a-zA-Z0-9_)
>
Thanks, I appreciate your reply.

\w\s\w has been working for me for some time with multiple characters 
in each word, such as "Leonard Sitongia" (it's a text input for a 
person's name).  I just recently discovered that it is also working for 
"Leonard E Sitongia", which I didn't want.  So, I assumed that \w mean 
word, not one character.

I'll try your suggestion.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validator mask boundary matchers don't work

Posted by Robert McBride <ar...@shaw.ca>.
Leonard,

Lets see if I can help, I hope my regex skills aren't totally rusty.

That regualar expression will only match exactly one word character then 
one whitespace character
then another word character. (A word character is in the set of a-zA-Z0-9_)

Try using this regex <var-value>^\w*\s\w*$</var-value> hopefully it will 
solve your problem.

-Rob

Leonard Sitongia wrote:

> I'm using Struts 1.1.  I have an html:text input field.
>
> I'm trying to constrain the input field to be two strings separated by 
> a space.
>
> I have tried
>
>             <var-value>\w\s\w</var-value>
>
> but that allows two *or more* strings separated by spaces, such as 
> "xxx yyy zzz".
>
> I have tried using the boundary matchers, as in
>
>             <var-value>^\w\s\w$</var-value>
>
> Then no input works.  I thought I read that ^ and $ are required in 
> 1.1, but I can't get it to work with them.
> It's not then expecting literal ^ and $, but I don't know what it's 
> doing.
>
> TIA.
> ==Leonard E. Sitongia
>   VETS / Scientific Computing Division
>   National Center for Atmospheric Research
>   P.O. Box 3000 Boulder CO 80307  USA
>   sitongia@ucar.edu    voice: (303)497-2454   fax: (303)497-1829
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org