How i can replace any character except 0-9 a-z and and array of some characters with ” (nothing).
My code is look like this
Var pCharArray = ['l', 'o', 'c'];//local characters
Var stringOrginal = 'Some Text';
stringOrginal.replace(/(^[0-9][a-z]pCharArray)/g, '');
Every character that is not 0-9 AND not a-z AND not in pCharArray, should be removed.
^ character means negation only when used inside of character class, i.e. [^a] means any character except a. When it’s used outside of the character class it means the beginning of the string.
Correct code:
Also please note if you want to include backslash or closing bracket to the pCharArray array you should state them as ‘\\’ and ‘\]’ there respectively.