[rules-users] rule name regular expression
Edson Tirelli
tirelli at post.com
Thu Aug 2 10:09:24 EDT 2007
Hi, yes, close to that:
name returns [String name]
: ID { $name = $ID.text; }
| STRING { $name = getString( $STRING.text ); }
;
So, a rule name can be either an ID or a STRING. ID is what you got
already:
ID
:
('a'..'z'|'A'..'Z'|'_'|'$'|'\u00c0'..'\u00ff')('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'\u00c0'..'\u00ff')*
;
A String is a valid Java string... so pretty much anything enclosed in
either " or '.
STRING
: ('"' ( EscapeSequence | ~('\\'|'"') )* '"')
| ('\'' ( EscapeSequence | ~('\\'|'\'') )* '\'')
;
In other words, if you want to allow the user to write rule names and
don't want to bother in validating it, just enclose the rule name in " and
be done with it. The only thing that may be good is to limit the length of
the string... you may want to use a hard limit around 60 characters I guess.
[]s
Edson
[]s
Edson
2007/8/2, hypnosat7 <ablarbi at yahoo.fr>:
>
>
> No I mean how can I check the validity of the rule names before put it in
> a
> DB, maybe I have to look to DRL.g grammar file ?
> is it this :
>
> ID
> :
>
> ('a'..'z'|'A'..'Z'|'_'|'$'|'\u00c0'..'\u00ff')('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'\u00c0'..'\u00ff')*
>
> thanks
>
>
>
> Mark Proctor wrote:
> >
> > There is no regexp for this. Easiest thing to do is make a package with
> > a single rule in it and pass it into a packagebuilder session.
> >
> > Mark
> > hypnosat7 wrote:
> >> Hi,
> >> When can I find the regular expression to check the validity of a
> rule
> >> name ?
> >> thanks
> >>
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/rule-name-regular-expression-tf4201280.html#a11959690
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070802/25093031/attachment.html
More information about the rules-users
mailing list