<html>
<body>
<script type="text/javascript">

var str = "r'i`t\"291134837u";
var invalidChar = new RegExp("[\',\",\`]","gi");
document.write(str.match(invalidChar));
</script>

</body>
</html>

I just want my regular expression to match a backslash. Thats all.
Tried giving [\\]. Aint working. Tried[\x5c] not working. But this hexadecimal character match is working for all the other characters.

Its so silly. I'm not able to do.. :'(

Ok. I got it to work with [\\\\]. But i didn't understand why you need four. They had tried explaining in that site but i didn't understand.

How about "var regex = /\\/ig;"
Try that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.