Reputation: 419
I'm using Regex to get part of my text but I can't use the result as conditional statement. Even using [1]
to select only the result after Regex, my condition can't work.
var dec = "> PRZ ##"
var cursodec = /\>([^#>]+)\##/.exec(dec);
var cursodecl = cursodec[1];
if (cursodecl == "PRZ") {
...
}
Any solution for that? Thanks!
Upvotes: 2
Views: 133
Reputation: 68393
change your regex to
var cursodec = /\>\s([^#>]+)\s\##/.exec(dec);
to account for space on both sides
Upvotes: 3