K
K
killerdr2019-03-07 08:24:52
Regular Expressions
killerdr, 2019-03-07 08:24:52

How to understand PHP regular expressions?

Help me understand how to compose regular expressions, well, I don’t understand, I manul this function.
here is an example that works as it should and allows you to get image links.

preg_match_all('/<img[^>]*'.'src=[\"|\'](.*)[\"|\']/Ui', $web_page, $images);

Please help me to understand what all these signs mean in this expression.
For example - <img[^>]*- how to understand it? or (.*)- what is it? and why in the $images array there will be exactly links, and not the entire element <img ...../>
Well, actually, how to make a regular expression to get the same links from a tag
<a ...... href="/img" .......>.....</a>or how to get the contents of the entire element<div class="content"> TEXT который надо </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-03-07
@LazyTalent

https://regex101.com/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question