Something along these lines:
var result;
result = value.match(/\/url\/([0-9]+)\/test/);
// use result[1] to get the numbers (the first capture group)
That relies on the /url/
and /test
bits, since you said they were reliable. More generally, this will match the first run of digits in the string:
var result;
result = value.match(/[0-9]+/);
// use result[0] (not result[1]), which is the total match
The MDC page on regular expressions is pretty useful.
Note: Instead of [0-9]
above, you can use \d
which stands for "digit". I don't because my regex-fu is weak and I can never remember it (and when I do, I can never remember whether it's all digits or all non-digits [which is \D
-- you see my confusion]. I find [0-9]
really clear when I read it later. Others may find \d
clearer, but for me, I like the explicit-ness of listing the range.