Home > Net >  How to match and extract a regular expression pattern?
How to match and extract a regular expression pattern?

Time:06-08

I have a string like so - SampleReleaseFY20Q3.STRY0122544.Developer.SDLCRework.6

Now, I would like to extract the pattern STRY******* and store it in a variable. So in this case, I would like to extract STRY0122544 and store it in a variable.

Any help with this is appreciated!

Thanks, Raskill

CodePudding user response:

We can use string match here:

var input = "SampleReleaseFY20Q3.STRY0122544.Developer.SDLCRework.6";
var output = input.match(/STRY\d /)[0];
console.log(output);

  • Related