handling pse in replace
This commit is contained in:
1 parent
9edc935f2d
commit
3ad9395c20
1 file changed
+8
@@ -24,6 +24,7 @@ import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
public class Sys {
|
||||
public static final Random randomizer = new Random();
|
||||
@@ -160,7 +161,14 @@ public class Sys {
|
||||
String replacement = "";
|
||||
if (lv.size() == 3)
|
||||
replacement = lv.get(2).getString();
|
||||
try
|
||||
{
|
||||
return new StringValue(data.replaceAll(regex, replacement));
|
||||
}
|
||||
catch (PatternSyntaxException pse)
|
||||
{
|
||||
throw new InternalExpressionException("Incorrect pattern for replace: "+pse.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
expression.addFunction("replace_first", (lv) ->
|
||||
|
||||
Reference in new issue
Block a user