I've searched everywhere and couldn't find any similar problem.
So I wanted to get the entire string in between delimiters with a specific text inside it.
Example:
I wanted to get the whole string in between "
that contains the text hotelscombined.com
This is the string to be searched from:
<a id="fake-id" href="http://hotelscombined.com?param=1¶m=2¶m=3">"Hello I'm a link"</a>
Result should be http://hotelscombined.com?param=1¶m=2¶m=3
and not Hello world
or fake-id
This is not limited to HTML/XML attributes only. It could be done on non-HTML/XML elements
Example:
Content to be searched:
Hello world I'm not an "html or xml" I could be "just random text"
Text to be match, anything that has the word random
and surrounded by quotes "
So "just random text"
is matched.
I tried it here https://regex101.com/r/qI8bS4/1 using this regex \".*?(hotelscombined\.com).*?\"
However it seems to be greedy and reaches to the next quote "
.