regex-Simple Regular Expression parsing problem

Source: Internet
Author: User
Keywords Regex php Java
Regexphpjava

The following is the other side to the parsing template PHP regular, want to use in Java, because it is a small white, hope to get everyone's help, thanks, thank you!!
My question: I understand preg_replace (); This method requires three parameters, the first is a regular expression, the second is a replacement string, the third is the template code, and finally the replacement template code is returned. In Java, the first parameter error, do not know if the syntax is not correct, if in Java and how to use, I hope the heroes pointing!!
/**
* Parsing templates
*
* @param $str Template content
* @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 Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.