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.
1 2 3 4 |
preg_match_all('#\b(https?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#ism', $text, $urls); $urls = $urls[1]; $urls = array_unique($urls); print_r($urls); |
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.