Tak ja ti pomuzu googlovat, dobre.
1. otevres stranku google.com (ono to presmeruje na google.cz)
2. do vyhledavaciho policka zadas: php regullar expression tag params
3. kliknes na prvni nalezenou stranku, shodou okolnosti manual a tam je
$patterns = array(
"/\[link\](.*?)\[\/link\]/",
"/\[url\](.*?)\[\/url\]/",
"/\[img\](.*?)\[\/img\]/",
"/\[b\](.*?)\[\/b\]/",
"/\[u\](.*?)\[\/u\]/",
"/\[i\](.*?)\[\/i\]/"
);
$replacements = array(
"<a href=\"\\1\">\\1</a>",
"<a href=\"\\1\">\\1</a>",
"<img src=\"\\1\">",
"<b>\\1</b>",
"<u>\\1</u>",
"<i>\\1</i>"
);
$newText = preg_replace($patterns,$replacements, $text);
---
function strip_selected_tags($str, $tags = "", $stripContent = false)
{
preg_match_all("/<([^>]+)>/i", $tags, $allTags, PREG_PATTERN_ORDER);
$replace = "%(<$tag.*?>)(.*?)(<\/$tag.*?>)%is";
foreach ($allTags[1] as $tag) {
if ($stripContent) {
$str = preg_replace($replace,'',$str);
}
$str = preg_replace($replace,'${2}',$str);
}
return $str;
}
?>
3b. Asi paty odkaz vede na stackoverflow, pomerne zname forko plne uzitecnych rad
https://stackoverflow.com/…apture-group
Parsovani url, to je podobne.
<?php
$str="member.php?action=bla&arg=2&test=15&schedule=16#test";
preg_match_all('/([^?&=#]+)=([^&#]*)/',$str,$m);
print_r($m);
//combine the keys and values onto an assoc array
$data=array_combine( $m[1], $m[2]);
print_r($data);
?>
3c. Dalsi link ze stack, a tam odkaz na demicko
https://regex101.com/r/kG5vF1/4
Pomoci vyrazu
/(?:<html|(?<!^)\G)\h*(?:([^=\n\h]+)=(['"])((?:\\\2|(?!\2).)*)\2)?/gmi
Parsuji
<html>
<html lang="en">
<html class="my-class">
<html class="my-class" lang="en">
No, a proc to neresis html parserem?
google = php html parse
http://php.net/…tml.php
$doc = new DOMDocument();
$doc->loadHTML("<html><body>Test<br></body></html>");
echo $doc->saveHTML();
?>
---
<?php
$doc = new DOMDocument();
$doc->loadHTML('<?xml encoding="UTF-8">' . $html);
// dirty fix
foreach ($doc->childNodes as $item)
if ($item->nodeType == XML_PI_NODE)
$doc->removeChild($item); // remove hack
$doc->encoding = 'UTF-8'; // insert proper
?>