How to find links to another domain?

In the array are strings of the form:
<a href="/onw">one</a>
<a href="twoo">one</a>
<a href="#">three</a>
<a href="https://mysite.ru">four</a>"
<a href="https://mysite.ru/news">five</a>"
<a href="https://vk.com/feed">six</a>"

How to determine how many external links on a page is if the native domain mysite.ru known in advance?
Thought to find of the regular season something like
href=\"(http:\/\//https:\/\/)все_кроме_mysite.ru
but failed to make the regular season
July 8th 19 at 15:21
2 answers
July 8th 19 at 15:23
Solution
https://regex101.com/r/hZ1iF6/3

Actually you can still find fault, to add a bunch of options, but for specific instances work.

href="(https?:\/\/(?!mysite\.ru\/?).+?)"
July 8th 19 at 15:25
Yes, that's the regular season.
can be broken down into tasks.

foreach( $links as $link ){
 if( stripos( $link, $siteName ) === false ){
 if( preg_match('#^(http\:\/\/|https\:\/\/)#', $link) ){
 // Some actions
}
}
}


1. Check is enter the domain name of the website.
2. Check whether links to linked third party online and check the line beginning with http or https.
3. Do some operation.
stripos( $link, $siteName ) === false - this condition will display all the internal links - alva8 commented on July 8th 19 at 15:28
true that's why I can't immediately check the entry of the domain - Tyreek.Stoke commented on July 8th 19 at 15:31
stripos( $link, $siteName ) === false - this condition will display all the internal links
what? here the division of tasks, in order not to bathe with the regular season, the second step cut off everything that leads to other resources.
If purely by the regular season, without the hassle, then the solution has already shown Mikhail Osher - Kaylah_Mraz82 commented on July 8th 19 at 15:34

Find more questions by tags Regular expressionsPHP