1

I'm trying to use regex for selecting all characters and words between the two ("...") in all tags, by certain pattern for example select which starts from /desktop/content.

I'm sure this is fairly simple but couldn't make it on my own, can someone help?

Example:

<img src="/desktop/content/img/illustrations/small-flower2.svg" width="138"/>

selected part should be: /desktop/content/img/illustrations/small-flower2.svg

0

1 Answer 1

1

you mean a regex like /"someQuotedString([^"]*)"/gm ?

var str = '<img src="/desktop/content/img/illustrations/small-flower2.svg" width="138"/>';

console.dir(str.match(/"\/desktop\/content([^"]*)"/gm));
console.log(str.match(/"\/desktop\/content([^"]*)"/gm)[0]);

https://regex101.com/r/ahjdCZ/1

...if you really want to make sure it's an <img... tag you could also:

/(?!<img.*)"([^"]+)"/

or within any < > tag:

/<.*"(\/desktop\/content[^"]+)".*>/
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.