1

I have the message string as follows.

string=052

I need to use regular expression not split.

I want to return everything past the equals. 052 This is what i tried and gives me id=null

var regex = '[^?string=]';
var id2 = mystring.match(regex);

I have tried online regex checkers and it looks like it matches all but the a

is there a better reg ex i should try? id should not equal null.

1 Answers1

1

You're using String.match() incorrectly. Try this:

var regex = '^message=(.*)$';
var id = queryString.match(regex)[1];

.match() returns an array; the first element (at [0]) is the entire matched string, and the second element (at [1]) is the part that's matched in the (first) set of parentheses in the regex.

Blazemonger
  • 82,329
  • 24
  • 132
  • 176