I have a regex in a variable
The purpose of my regex is to list down all of allowable characters for user input
Note that the regex may change from time to time depending on the user preference
var regex = new RegExp(passParamStateMap.value, "g");
The value of my regex after console.log is
/~@#$%^&*()_+{}[]:;<>,.?\//g
However, when I try to match it with user input, I am getting null
value
Can someone enlighten me please.
var regex = new RegExp(passParamStateMap.value, "g");
if( e.target.value.match(regex) ){ //null value
passError.concat("allowable")
}
Sample use case:
- User edits in password parameter maintenance module the field
Allowable Special Characters
- User defined these as allowable:
~@#$%^&*()_+{}[]:;<>,.?
- Now, on my
New Password
field, the only allowable special characters are the ff:~@#$%^&*()_+{}[]:;<>,.?
- Can I achieve this requirement using regex? Note that the value
~@#$%^&*()_+{}[]:;<>,.?
may change