I have, what I thought was, a simple regex to get anything not (letter), (number) or (%)
str.indexOf(/[^a-zA-Z0-9%]/);
However, I'm ALWAYS getting -1.
Here's an example str:
Check out this awesome video!
What am I doing wrong?
I have, what I thought was, a simple regex to get anything not (letter), (number) or (%)
str.indexOf(/[^a-zA-Z0-9%]/);
However, I'm ALWAYS getting -1.
Here's an example str:
Check out this awesome video!
What am I doing wrong?
 
    
    You cannot put regex into indexOf. Use search instead.
See this for more info: Is there a version of JavaScript's String.indexOf() that allows for regular expressions?
"Check out this awesome video!".replace(/./g,function(match){
  return '0x'+match.charCodeAt(0).toString(16);
});
returns the hexadecimal representation of the string. If you want just convert alpha-numeric characters, replace the . in the regex by \w.
