I would like to extract particular piece of text MH4
from the string S12345-MH4-PX
through javascript regular expressions.
The desired output should be MH4.
I would like to extract particular piece of text MH4
from the string S12345-MH4-PX
through javascript regular expressions.
The desired output should be MH4.
You can use something like:
var input = 'S12345-MH4-PX';
var reg = /\-(.*)-/g;
var matches = reg.exec(input);
console.log(matches[1]);