[rules-users] mvel regex not working???

Carlsen, Len len.carlsen at ubc.ca
Wed Nov 14 19:17:46 EST 2007


Hi,

 

I have an email validation regex where the mvel matches doesn't seem to
work. I have created 2 rules where test1 uses the Java String matches
and test2 uses the mvel matches. Test1 works but test2 doesn't. I am
using Drools 4.0.3 and JDK 1.6.0_02.

 

rule "Test1"

    when

        // This works

        email : String()

        eval( !email.matches(
"^[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+(
\\.[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+
)*@[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9
-]{0,61}[a-zA-Z0-9])?)*\\.[a-zA-Z]{2,6}$" ) )

    then

        System.out.println( "1-Invalid Email Address: " + email );

end

 

rule "Test2"

    when

        // This doesn't work

        email : String( toString not matches
"^[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+(
\\.[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+
)*@[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9
-]{0,61}[a-zA-Z0-9])?)*\\.[a-zA-Z]{2,6}$" )

    then

        System.out.println( "2-Invalid Email Address: " + email );

end

 

Here's the output using email addresses x.x at x.com (valid) and x.xx.com
(invalid):

 

test1-Invalid Email Address: x.xx.com

test2-Invalid Email Address: x.x at x.com

test2-Invalid Email Address: x.xx.com

 

The regex expressions are exactly the same. Am I doing something wrong
here?

 

Thanks,

 

Len

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071114/8aca5672/attachment.html 


More information about the rules-users mailing list