In JavaScript, given a regexp pattern and a string:
var pattern = \'/this/[0-9a-zA-Z]+/that/[0-9a-zA-Z]+\';
var str = \'/this/12/that/34\';
How
Use capture groups:
var res1 = '/this/12/that/34'.match(/\/this\/([0-9a-zA-Z]+)\/that\/([0-9a-zA-Z]+)/);
You will get an array containing 3 elements:
The whole match;
12
34
And you can use .slice(1)
to remove the first element:
var res1 = '/this/12/that/34'.match(/\/this\/([0-9a-zA-Z]+)\/that\/([0-9a-zA-Z]+)/).slice(1);