You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by James Strachan <ja...@yahoo.co.uk> on 2003/01/28 14:37:50 UTC

Re: [jelly] Regexp ?

From: "Stéphane MOR" <st...@yahoo.fr>
> I'm trying to set variables with a Perl5 regexp pattern, such as :
>    <j:set var="net-ip"
>
value="^((?:0*)(?:(?:1(?:\d{1,2})|2(?:[0-4]\d|5[0-5]))|\d{1,2})(?:\.|$)){4}"
/>
>
> This doesn't want to work and always returns 0 (zero).
> This probably comes from the {} and $ that are inside the regexp.

You could use $$ to avoid the $ being inerpreted as an expression.

> Is there a way to disable Jelly evaluation before setting the variable,
> so that it would be sent
> 'as is' and Jelly would not try and evaluate it first ?

There are a few options. A TagLibrary can decide what ExpressionFactory to
use; so for example you could write a special regexp Tag that the value is
interpreted literally as a regexp without any expression evaluation. The XML
tag libraries do this to add native XPath expressions. ditto with beanshell,
BSF etc.


> Something like "evaluateAttributes(boolean)" at the Tag level that would
> be checked by Jelly before
> trying to evaluate, or something like that ...

A TagLibrary gets to decide how an XML attribute value is converted into an
expression via this method

public Expression createExpression(
    ExpressionFactory factory,
    TagScript tagScript,
    String attributeName,
    String attributeValue);

So you can do this on a per-tag library basis.

James
-------
http://radio.weblogs.com/0112098/


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org