struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brady Hegberg <bra...@bitstream.net>
Subject Re: [OT] Help with REgular Expressions in Validate()
Date Fri, 20 May 2005 23:20:03 GMT
I have a small swing application (setup on webstart) for testing regular
expressions here:
http://lili.net/java/test-regex.jnlp

Or I can send you the code to test it yourself if you wish.  it won't
fix your problem but it's a handy tool for narrowing it down.

Brady

> Hi all
> I markled this OT because it's not a Struts question strictly speaking.
> 
> what I'm trying to do is disallow names that contain spaces or special 
> characters in the validate() method of my ActionForm
> 
> Code:
> String pattern = "\\W+";
> log.debug("Testing validity of name "+name+ " against "+pattern);
> if (name!=null){
> if (name.matches(pattern)) {
> log.info("Naming Convention Violated");
> e = new ActionError("error.create.portfolio.name.error");
> errors.add("",new ActionError("error.create.portfolio.name.error"));
> }else{
> log.debug("Valid name chosen");
> }
> }
> What am I missing?!?!?! I always get "valid name chosen" 
>  Again, I want to allow "MyNAme" and disallow "My Name" or "MyName!" (due to 
> spaces or special characters
> 
> 
-- 
Brady Hegberg <bradyh@bitstream.net>


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


Mime
View raw message