php通过正则表达式进行字符串搜索的简单范例
<?php $string_to_search = "w3mentor.com"; $regex = "/tor/"; $num_matches = preg_match($regex, $string_to_search); if ($num_matches > 0) { echo "Found a match!"; } else { echo "No match. Sorry."; } ?>
php通过正则表达式进行字符串搜索的简单范例
<?php $string_to_search = "w3mentor.com"; $regex = "/tor/"; $num_matches = preg_match($regex, $string_to_search); if ($num_matches > 0) { echo "Found a match!"; } else { echo "No match. Sorry."; } ?>