經常使用HTML正則

<?php

//HTML a鏈接正則
$str = '';
$isMatched = preg_match('/<a.*?[^<]>.*?<\/a>/', $str, $matches);
var_dump($isMatched, $matches);


//HTML js正則
$str = '';
$isMatched = preg_match('/<script[\s\S]*?<\/script>/', $str, $matches);
var_dump($isMatched, $matches);

//HTML img正則
$str = '';
$isMatched = preg_match('/<img[^>]*>/', $str, $matches);
var_dump($isMatched, $matches);
相關文章
相關標籤/搜索