regex-简单正则表达式解析问题

WBOY
Release: 2016-06-02 11:34:56
Original
1100 people have browsed it

regexphpjava

以下为对方给的解析模板的php正则,想在java里使用,因为是正则小白,希望得到大家的帮助,感激,谢谢!!
我的疑问:我对preg_replace()理解;此方法需要三个参数,第一个为正则表达式,第二个为替换成的字符串,第三个为模板代码,最终返回替换后的模板代码。在java中第一个参数报错,不知道是不是语法不对,如果在java中又该如何使用,希望大侠们指点!!
/**
* 解析模板
*
* @param $str 模板内容
* @return ture
*/
public function template_parse($str) {
$str = preg_replace ( "/{view\s+(.+)}/", "", $str );
$str = preg_replace ( "/{template\s+(.+)}/", "", $str );
$str = preg_replace ( "/{include\s+(.+)}/", "", $str );
return $str;
}

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template