I am new to JavaScipt and testing a regular Expression and is working on below use case -
Requirement - Replace every character with '#' that is NOT FROM BELOW LIST-
- Number
- Character (upper or lower case)
- Any special character except -> comma, dot, square brackets, forward slash, single Quote
Please find my code below -
var replacedStr = str.replace(/[^a-zA-Z0-9'.-\[\], ]/g,"#");
Output for various values of str are -
str = "hello_";
replacedStr is hello#
_______________________
str = "hello@_";
replacedStr is hello@#
I wanted to know why '@' isnot being replaced from above regex.
The same behavior is with characters - underScore, question-Mark, Angular brackets.
Please guide.
Thanks,
Vibhav