Answer the question
In order to leave comments, you need to log in
How to get an array of search strings in a string?
There is text (regular string)
Lorem ipsum 'vendor/js/srcipt.js' dolor sit amet, 'lib/ls/jquery/jquery.min.js' consectetur 'img/pict.jpg' adipisicing 'vendor/style/some-style.min.css' elit. Adipisci, tenetur?
vendor
and end with js
or css
, but without the word vendor ['js/srcipt.js', 'style/some-style.min.css']
Answer the question
In order to leave comments, you need to log in
var testStr = "Lorem ipsum 'vendor/js/srcipt.js' dolor sit amet, 'lib/ls/jquery/jquery.min.js' consectetur 'img/pict.jpg' adipisicing 'vendor/style/some-style.min.css' 'vendor/style/some-style.less' или 'vendor/img/bla.png' elit. Adipisci, tenetur?";
var reqExpWrapper = new RegExp('(?:vendor/)((?:.*?)\\.(?:css|js))\'', 'g');
var matches = new Array();
while(match = reqExpWrapper.exec(testStr))
{
matches.push(match[1]);
}
console.log(matches);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question