A
A
Andrey Vaganych2016-12-18 12:00:19
BBCode
Andrey Vaganych, 2016-12-18 12:00:19

How to limit the construction (.+?)?

The essence of the task is:
There is a text with links in the format of a bb-code of the form:
1) [url=" https://wordpress.org/ "]Regular link[/url]
2) [url=" https://wordpress.org / " target="_blank"]Normal link in new window[/url]
The regular expression needs to find only the exact match. I found the option /\[url=\"(.+?)\"\](.+?)\[\/url\]/s, but it also works for cases 1 and 2. I need to find only 1 number.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2016-12-18
@Maksim12

/\[url=\"([^\s"]+?)\"\](.+?)\[\/url\]/s
https://regex101.com/r/e4aZgb/1

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question