E
E
elfix2020-06-13 13:41:22
PHP
elfix, 2020-06-13 13:41:22

How to capture only up to the first quote?

Expression:
<h.*>.*<a.*href='(.*)'>.*<\/a>.*<\/h.*>
Text:

<h1 class='blablabla'><a class='Title' href='https://www.url.com' rel='rel'>blablabla</a></h1>


Result, captures with two extra quotes:
https://www.url.com' rel='rel
And you only need the url before the quote
https://www.url.com

In the simulator: https://regex101.com/r/R9Vq8M/1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Kalenchukov, 2020-07-05
@kalenchukov

There is a concept of "greed" in regular expressions. Read about it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question