I want something like this:
\"abcdab\".search(/a/g) //return [0,4]
Is it possible?
If you only want to find simple characters, or character sequences, you can use indexOf [MDN]:
var haystack = "abcdab", needle = "a" index = -1, result = []; while((index = haystack.indexOf(needle, index + 1)) > -1) { result.push(index); }