0

I have this pattern which finds links, inside a text string from file_get_contents function.

Works fine, it seems. But I am curious to understand the expression, each charachter of it, what it does etc.

Here you go:

preg_match_all('~href=("|\')(.*?)\1~', $var, $out);

I know what it does obviously, but what does (.*?)\1~ do?

What does this ~ mean? Is that just the start and end delimeter used i this case? So that could also be // (start, end)?

Finally, any good simple source where I can read up on these expressions, from beginner to more advanced level?

All the best, Klemme

Edited by klemme

3
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by klemme
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.