Answer the question
In order to leave comments, you need to log in
How to write a regular expression with negation?
We need a regular expression that searches from links and selects those that lead not to pages, but to pictures, for example. Those. with extension. But with an extension other than html, php, etc. Please note that pages are without extension.
I made this one:
preg_match("#\.(?!htm|html|asp|aspx|php)$#Uum", $url)
Answer the question
In order to leave comments, you need to log in
In general, I solved the problem with two if
if (preg_match("#/[^.]*\.[^.]*$#Uui", $url)) {
if (preg_match("#(?<!htm|html|asp|aspx|php)$#Uui", $url)) {
continue;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question