json-schema-validator-demo
json-schema-validator-demo copied to clipboard
Case insensitive regex not working
I looked into library. I found below regex is giving false result. RhinoHelper is not supporting case insensitive regex support properly.
String regex = "/^[a-zA-Z0-9_.+-]+@(?:(?:[a-zA-Z0-9-]+.)?[a-zA-Z]+.)?(gmail.com)$/gi";
boolean result = RhinoHelper.regMatch(regex,"[email protected]");
```
As RhinoHelper class is using RegExp function of javascript to validate and match RegEx. Java is passing regex as String in that javascript call.

but actual javascript accept regex without double quote. How would I achieve in java this behavior. Because with double quotes regex was giving correct result earlier untill and unless I tried case insensitiveness. If I pass regex without double quotes, It will work but not with double quotes
So if have to use case insensitiveness nature of this function, we have to pass "i" as second argument not like
`/gi`

Internal function used by RhinoHelper class to validate and match regex
function regexIsValid(re) { try { new RegExp(re); return true; } catch (e) { return false; } }
function regMatch(re, input) { return new RegExp(re).test(input); }