-
New Feature
-
Resolution: Done
-
Normal
-
9.5.1.2
-
Security Level: Jimmy
User Story
As an app developer, I want to use all regular expression flags that browsers support so that I can perform various validations.
Acceptance Criteria
<textbox constraint="/^[\p{L}\p{P}\p{Z}\p{N}\|]{1,32}$/gmu"></textbox>
The flag is gmu
Details
When creating RegExp, we pass a fixed flag g (see code), it's better to pass the complete regular expression specified by app developers, so that the developers can utilize all regular expression features that browsers support.
Workaround
If you want to use the Java Pattern flags, you can try server side validation with Embedded Flag Expressions
(?iu) means Pattern.CASE_INSENSITIVE and Pattern.UNICODE_CASE
<zscript><![CDATA[ public class MyConstraint extends SimpleConstraint implements CustomConstraint { // server side validation public MyConstraint() { super("no empty, /(?iu)[A-Z]{3}/"); } public void showCustomError(Component comp, WrongValueException ex) { comp.getFellow("errlb").setValue(ex != null ? ex.getMessage(): ""); } }; MyConstraint myc = new MyConstraint(); ]]></zscript> <hlayout> <textbox constraint="${myc}"/> <label id="errlb" style="color:red"/> </hlayout>