I want to check whether my userid is having any special character apart from alphanumeric characters (a-z,A-Z,0-9). The below regex is failing...what would be the correct way?
var testStr = '3278|3278.3000.2506.60200000.1100.000.0000.0||703"68*[70"8'; var splitTeststr = testStr.split('|'); alert(splitTeststr[0]); /* alert('Length of splitStr is : ' +splitTeststr.length); */ if (splitTeststr.length == 4) { var userId = splitTeststr[3].trim(); alert('userId before removing junk : ' +userId); var letterNumber = /^[0-9a-zA-Z]+$/; if((userId.match(letterNumber))){ alert('UserId contains junk : ' +userId); }else{ alert('Userid is fine'); } }
varandalert. This is so recurring on SO that I'm starting wondering if they're all from the same source