Groovy RegEx Expression in DMN Input

Can someone give me the syntax of the a Groovy expression that uses RegEx in the INPUT column of a DMN table?

I have a fairly complex RegEx string (shown below) that matches my entire input 100%. I cannot make it work. I think it’s something like: matches(‘…’), but nothing works or it just throws errors.

(.*\n)*.*\\\"eventSource\\\":\\\"bmp\\\"(.*\n)*.*\\\"ticketEventType\\\":\\\"15\\\"(.*\n)*

Thank you.

Hi @mppfor_manu,

note that forum is for topics related to Camunda and not for generally groovy things :wink:

However, you may have a look at this tutorial. What did you tried?

Best regards,
Philipp

Phillip,

As always, thank you for your prompt replies.

However, this IS about Camunda DMN. It isn’t the specific Groovy syntax that is the issue as much as how it is actually encoded (typed into Modeler) so that it works. We would even be okay with directly editing DMN table XML.

What we are trying to do is to input a message and determine an arbitrary “type” for it without regard to its syntax (i.e. JSON, XML, unstructured text). I know the RegEx in my original post works (although in JavaScript on the regex101 website) and uniquely matches the entire message. So, the RegEx isn’t the problem.

Just dropping the RegEx above into an input column and setting the expression language to “groovy” doesn’t work at all. We have used the following form with very simple RegEx expressions:

(cellInput =~ /asdf/).asBoolean()

Which Modeler renders as the following in XML:

<![CHAR[(cellInput =~ /asdf/).asBoolean()]]>

This sort of works. We have tried directly editing the XML to remove the CHAR tags, but Camunda just throws “null key” errors when you evaluate the DMN table. We have also read just about every available post or page that includes “Camunda” and “RegEx”. The only thing we haven’t done is actually crack open the source code to see how the Groovy expressions are evaluated (we bought Camunda software so we wouldn’t have to do things like this).

You folks are great, but the documentation on the use of expressions within Camunda in general and DMN specifically, needs a lot of work. We just want clear examples of how to use a regular expression (like my example in the first post) in a DMN table input column. I guess I don’t even care about the language anymore.

Michael

SOLVED IT!!! This is the actual XML:

(cellInput =~ /(.|\n)(“ticketEventType”:“19”)(.|\n)(“eventSource”:“bmp”)(.|\n)*/).asBoolean()

NOTE: Modeler will try to surround this with the <![CHAR[]]> tags, which must then be manually removed by directly editing the XML.

Our “mistake” was assuming we had to escape the “escape” characters that are found in the original message. That message contains “stringified” JSON, thus all quotation marks within the actual message (which is just standard JSON). In other words, we’re getting a JSON message wherein a value field contains JSON.

When translating this into RegEx on the regex101 web site (which doesn’t directly evaluate expressions for the Groovy language), we needed these escapes within the RegEx.