Reputation: 12695
I wondering how should be the regex string for the string containig '#'
e.g.
abc#def#ghj#ijk
I wanna get
I tried #[\S]+
but it selects the whole #def#ghj#ijk
Any ideas ?
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";
}
}
the double backslash solved that problem. '#[^\\s#]+'
Upvotes: 0
Views: 123
Reputation: 60868
Try #[^\s#]+
to match #
followed by a sequence of one or mor characters which are neither #
nor whitespace.
Upvotes: 3