I wondering how should be the regex string for the string containig ‘#’
e.g.
abc#def#ghj#ijk
I wanna get
- #def
- #ghj
- #ijk
I tried #[\S]+ but it selects the whole #def#ghj#ijk Any ideas ?
Edit
The code below selects only #Me instead of #MessageBox. Why ?
var m = new RegExp('#[^\s#]+').exec('http://localhost/Lorem/10#MessageBox');
if (m != null) {
var s = '';
for (i = 0; i < m.length; i++) {
s = s + m[i] + "\n";
}
}
Edit 2
the double backslash solved that problem. '#[^\\s#]+'
Try
#[^\s#]+to match#followed by a sequence of one or mor characters which are neither#nor whitespace.