I am clueless about regular expressions, but I know that they're the right tool for what I'm trying to do here: I'm trying to extract a numerical value from a string like this one:
Ideally, I'd extract the following from it:
12345678901234567890123456789012 None of the regexes I've tried have worked. How can I get the value I want from this string?
mystr.match(/assignment_group=([^\^]+)/); //=> "12345678901234567890123456789012"
This will find everything from the end of "assignment_group=" up to the next caret
This will get all the numbers:
var myValue = /\d+/.exec(myString)
Try something like this:
This will get the number for
var str = 'approval=not requested^assignment_group=12345678901234567890123456789012^category=Test^contact_type=phone^', regex = /\^assignment_group=(\d*)\^/, matches = str.match(regex), id = matches !== null ? matches : ''; console.log(id);
If there is no chance of there being numbers anywhere but when you need them, you could just do:
the \d matches digits, and the + says "match any number of whatever this follows"
©2020 All rights reserved.