PHP regular expression reverse extraction

Source: Internet
Author: User
PHP regular expression reverse reference solution? Php reverse capture does not know what is going on. Remove the four consecutive numbers in the following string. Fsdfsdafasfasdfsdf <{2365}>? & Lt ;? Phpheader ("Content-t PHP regular expression reverse reference solution?
Use phpReverse capture does not know what is going on.

Remove the four consecutive numbers in the following string.

Fsdfsdafasfasdfsdf <{2365}>

In addition, please analyze what problems I have written?

 Header ("Content-type: text/html; charset = utf-8 ");
$ Str = "fsdfsdafasfasdfsdf <{2365}> ";
$ Mypreg = "/<{(\ d)}>/"; // () indicates four consecutive numbers, use parentheses to capture this subexpression and reference it later.
$ Mycon = "\ 1"; // This is the replacement content. I reverse reference the four numbers above 2365, use these four numbers to replace the entire block with an external symbol <{2365}>
Echo $ str;
Echo"
";
$ Str = preg_replace ($ mypreg, $ mycon, $ str );
Echo $ str;


The result is that <{2365}> is captured, but there is no content in the reverse reference. it should be that the reverse reference is wrong and the content is not referenced. Please advise. Share To:, please also analyze where I wrote the problem?
------ Solution --------------------
Isn't it the group name of the subexpression?
To specify the group name of a subexpression, use the following syntax :(? \ W +)
Word is the group name of the expression.
Syntax referenced later \ k

I am not familiar with new learning either.
------ Solution --------------------
$ Mycon = "\ 1 ";
Or
$ Mycon = '\ 1 ';

Yes

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.