The regexp taglib isn't included, only a small subset of taglibs are:
R:\clarity\15.7.0\lib>dir common*tag*
Volume in drive R is REGO
Volume Serial Number is 560E-45EC
Directory of R:\clarity\15.7.0\lib
08/27/2019 06:05 AM 9,503 commons-jelly-tags-email.jar
08/27/2019 06:05 AM 22,479 commons-jelly-tags-fmt.jar
08/27/2019 06:05 AM 18,042 commons-jelly-tags-jsl.jar
08/27/2019 06:05 AM 11,196 commons-jelly-tags-log.jar
08/27/2019 06:05 AM 32,514 commons-jelly-tags-sql.jar
08/27/2019 06:05 AM 16,888 commons-jelly-tags-util.jar
08/27/2019 06:05 AM 37,430 commons-jelly-tags-xml.jar
7 File(s) 148,052 bytes
0 Dir(s) 509,890,560 bytes free
R:\clarity\15.7.0\lib>
(Plus "core", "gel", and "bpm" for the most part).
Incidentally, just including the namespace entry into the <gel:script> tag doesn't actually use the taglib anywhere; you would then later on have to use a tag from it like <regexp:blahblah>, at which point you would then get an error telling you the classes for the taglib don't exist.
When you're doing things in an expression like ${...} you're using JEXL (v1.1)** instead.
JEXL has the ability to call java methods on its objects/variables, and so Gene's .matches() example will work because that's literally just calling the matches method of java.lang.string :
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#matches-java.lang.String-You can also, of course, use the JEXL to do the matching directly in the <core:if test="..." /> tag and don't have to do a <core:set> first, but I won't replicate the answer for that because Gene's is already adequate.
** Note that the available documentation for JEXL references using pattern matching expressions directly with =~ and !~ and other operators, but as far as I know these don't work as they were added in JEXL 3.x which Clarity doesn't use. So be careful with what the available documentation claims you can / can't do because finding 1.1 docs is a challenge. Apart from that, this is still a good reference and as above, you don't need to add ANY namespaces to use JEXL it's already present:
http://commons.apache.org/proper/commons-jexl/reference/syntax.html
Original Message:
Sent: 07-17-2020 05:43 AM
From: Christoph Schubert
Subject: GEL Script regular expression
Hi,
I try to check a variable, if it is 3 digits.
But I cannot get regex to work in GEL script.
Is it possible or what is the correct syntax?
I have included: xmlns:regexp="jelly:regexp"
Don't know if this is correct or needed
And when I try something like this (tried several syntax and masks things already)
<core:if test="${variableA.match(/^\d\d\d$/g)}"
or even
<core:if test="${variableA.match(\d\d\d)}"
I get an error "Unable to create expression". Or the if is never true.
Does somebody used regex in GEL scripts and can provide an example? I also found some older posts, that this is not possible.
------------------------------
Thanks and regards
Christoph
------------------------------