[rules-users] how to write regular expressions in drools..

Jaroslaw Kijanowski kijanowski at gmail.com
Fri May 30 06:02:48 EDT 2008


Yeah, but that's not a drools issue any more. I guess your regexp is not 
sufficient to catch an email address.
The rule will fire when you provide @aa but it will not fire if you use 
@aa.com, right? google for "Validate an Email Address" and you will find 
regexps which will handle the "dot" and other chars.

Cheers,
  Jarek

Nagaraju runkana wrote:
> HI Jar,
>  Thanks for replay,
>  i am try to like this also: email matches "@\[A-Za-z0-9\]*"
> in this case also nagetive test cases Build Success.
> 
> Chanti
> 
> On Fri, May 30, 2008 at 2:49 PM, Jaroslaw Kijanowski <
> jaroslaw.kijanowski at redhat.com> wrote:
> 
>> Hi,
>>  you have to escape characters with regexp meaning (see docs for details).
>> Try this:
>> email matches "@\[A-Za-z0-9\]*"
>> phone not matches "\\\\d{3}\\\\-\\\\d{3}\\\\-\\\\d{4}"
>>
>> Moreover I guess your rule is anyway broken, you will get a cross product
>> of Orders, so I would remove "There is an Order" from both rules.
>>
>> Cheers,
>>  Jarek
>>
>> Nagaraju runkana wrote:
>>
>>>  HI Guys,
>>>
>>> present i am using drools 4.0 in this case.now, i am writting some rules
>>> validation using regular expression ZIPCODE,EMAIL,CREDIT CARD number.like
>>> this..
>>> --------------------
>>> validation.dslr
>>> --------------------
>>> rule "email.mandatory:[insert][update][ui]"
>>>  when
>>>  There is an Order
>>>  Order email address checking for first letter
>>> then
>>>  Reject with response : "email address must not start with @ "
>>> end
>>> rule "phone.mandatory:[insert][update][ui]"
>>> when
>>>  There is an Order
>>>  Order phone number format should checking
>>>  then
>>>  Reject with response : "The phone number you entered is not valid.Please
>>> enter a phone number with the format xxx-xxx-xxxx."\
>>> end
>>> -----------------------
>>> validation.dsl
>>> --------------------
>>> [*][]Order email address checking for first letter= OrderBean(email
>>> matches
>>> "@[A-Za-z0-9]*")
>>> [*][]Order phone number format should checking=OrderBean( phone not
>>> matches
>>> "(/\d{3}\-\d{3}\-\d{4}/)==-1)")
>>> this rules are not working ...any one can help me.ASAP
>>>
>>> thanks,
>>> chanti
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list