php正则匹配一段文字 很简单 60分
PHP code<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> <span class="ball-type-1"> <var>1</var> <var>2</var> <var>3</var> <var>4</var> <var>5</var> </span>
匹配出 1 2 3 4 5 这5个数字就行了
谢谢了 在线刷新等
------解决方案--------------------$str=
1
2
3
4
5
html;
preg_match_all('#
(.*)#isU',$str,$arr);
print_r($arr[1]);
------解决方案--------------------preg_match_all('#
(\d+)#isU',$str,$arr);
------解决方案--------------------i: 表示in-casesensitive,即大小写不敏感
s: PCRE_DOTALL,表示点号可以匹配换行符。
U: 表示PCRE_UNGREEDY,表示非贪婪,相当于perl/python语言的.*?,在匹配过程中,对于.*正则,一有匹配立即执行,而不是等.*消费了所有字符再一一回退。
------解决方案--------------------PHP code<?php $str = <<<html <span class="ball-type-1"> <var>1</var> <var>2</var> <var>3</var> <var>4</var> <var>5</var> html;preg_match_all('#<var>(\d+)</var>#i', $str, $arr);print_r($arr[1]);<div class="clear">
</div>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn