What should I do if the preg_split () function is used in PHP to match the Regular Expression and retain the delimiter?

Source: Internet
Author: User
Requirement I need to split the following code into an array {code ...} PHP code: {code ...} the result is that the & amp; lt; & amp; gt; two symbols are lost. What can I do with the poly separator? Find the answer {code ...}

Requirement
I need to split the following code into arrays.

Caution: You will switch to sleep mode and cannot use the call, SMS, or network functions. Are you sure you want to change?

PHP code is


  ] +/"," \ "Caution: You will switch to sleep mode and cannot use the call, SMS, or network functions. Are you sure you want to change? \ ""); Echo"
";print_r($keywords);echo "
";?>

The effect is as follows:

Lost <> two symbols. How can I use the poly separator?

I found the answer.

$ Keywords = preg_split ('/([<|>] +)/', '"Caution: You will switch to sleep mode and cannot use the call, SMS, or network functions. Are you sure you want to change? "',-1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );

Reply content:

Requirement
I need to split the following code into arrays.

Caution: You will switch to sleep mode and cannot use the call, SMS, or network functions. Are you sure you want to change?

PHP code is


  ] +/"," \ "Caution: You will switch to sleep mode and cannot use the call, SMS, or network functions. Are you sure you want to change? \ ""); Echo"
";print_r($keywords);echo "
";?>

The effect is as follows:

Lost <> two symbols. How can I use the poly separator?

I found the answer.

$ Keywords = preg_split ('/([<|>] +)/', '"Caution: You will switch to sleep mode and cannot use the call, SMS, or network functions. Are you sure you want to change? "',-1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );

$ Keywords = preg_split ('/([<|>] +)/', '"Caution: You will switch to sleep mode and cannot use the call, SMS, or network functions. Are you sure you want to change? "',-1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );

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.