Ask questions about WordPress courses

Finding all links in a text. Parsing.

Regular expression find all links in text using php. It came in handy when I needed to select images from the standard content builder plugin and create a slider.

The standard plugin added a lot of extra html code and with the help of this regular expression it was possible to clean up all the extra and completely unnecessary code.

preg_match_all('#\b(https?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#ism', $text, $urls); 
$urls = $urls[1]; 
$urls = array_unique($urls);
print_r($urls);

Купить хостинг WordPress
WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal