Regular expressions may be used for string operations, which is complicated to solve.

Source: Internet
Author: User
Regular expressions may be used for string operations. a complex string may be used in the following format: & lt; br/& gt ;... & lt;/font & gt; & lt; br/& gt ;... & lt;/font & gt; & lt; br/& gt ;... & l operations on strings may require regular expressions and are complicated.
A string in the following format:


...

...

...
(That is, strings can be viewed
Start
Substring at the end of the string ).


Now I want:

Input an index value (for example, I). starting from 0, delete the sub-string I + 1 in this string. for example, if I = 1, delete the 2nd sub-strings in the original string
Start
The substring at the end of the string.


How can this problem be achieved?

------ Solution --------------------
Pcre_match_all ("/ (? :. | \ N | \ r) * <\/font> /IU ", $ str, $ array );
Echo"
";
Print_r ($ array );

You should have done the rest.
------ Solution --------------------
$ Str = preg_replace ('/(( . * <\/Font> ) {'. $ I .'}) . * <\/Font> /IsU ',' \ 1', $ str );
------ Solution --------------------
A little thing I don't quite understand
What is isU ???

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.