Last active
July 6, 2019 09:46
-
-
Save eto4detak/165f822b0765d4cf8261be57a51e809e to your computer and use it in GitHub Desktop.
php preg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$result = preg_match('/<spa.+>(.+)<\/span>/',$str,$found); | |
$result = preg_match('/<strong>(.+)<\\/strong>/',$str,$found); | |
$ulclass = preg_replace('/<a /', '<a class="cms30_link" onclick="yaCounter49161010.reachGoal(' . "'callback_click'" . '); return true;"', $ulclass, 1); | |
return preg_replace('/<a href/', '<a class="cms30_link" onclick="yaCounter49161010.reachGoal('."'calculate_click'".'); return true;" href', $ulclass, 1); | |
$new_key = preg_replace('/^\./', '', $new_key, 1); | |
// from a in span | |
$link = '<a href="https://natalex.eu/listings/2bdr-apartment/" rel="tag">2 bedroom apartment</a>,,,<a href="https://natalex.eu/listings/2bdr-apartment/" rel="tag">2 bedroom apartment</a>'; | |
$span = preg_replace('~<a.+href="(https?://.+?)"[^>]*>(.+)</a>~', '<span class="link" data-link="$1">$2</span>', $link); | |
// only a-z | |
$sku = preg_replace('/[^A-Za-z0-9\-_]/', '', $sku); | |
// cyr or lat | |
preg_replace("/[^а-яёa-z,]/iu", '', $target); | |
// find all link in text | |
preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $first_return->post_content, $match); | |
// find end link | |
preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $first_return->post_content, $match); | |
$all_link = $match[0]; | |
$result_count = preg_match('/([^\/]+)$/',$all_link[2],$matches); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment