Sks
Sks

Reputation: 610

How to Evaluate the Java syntax using Apache JEXL

I tried to use JEXL to evaluate the syntax but not getting through. Want your help guys to get it executed.

I want to evaluate dynamic replace statement (.replace("\u00A0","")) coming through ajax.

In Java -

removeSpecialChars = ".replace("\u00A0","");
text.replaceAll("\\p{Cntrl}", "");
text = text + removeSpecialChars;

How can we evaluate the text statement using JEXL.

Upvotes: 0

Views: 1712

Answers (1)

Ori Marko
Ori Marko

Reputation: 58882

You need to follow JEXL's tutorial

The easiest way of obtaining a a context is to use the new MapContext() statement. This creates a context implemented using an underlying HashMap

Expressions are created using the JexlEngine.createExpression(String) method.

Once you have your expression, you can then use use the evaluate to execute it and obtain a result.

Upvotes: 0

Related Questions