Delete adjacent duplicate content

Source: Internet
Author: User

1. Idea: match with regular expression, use reverse reference, replace. Find (. +?) \1 Replace with $
(. +) \1 why not? Because quantifier priority, + will eat as much as possible, and then another one spit out, inefficient, use (. +?) \1 cancel quantifier First, try to eat less.
(.*? Why \1 is not good, because. * can match no characters in the case,. + requires at least one character, since it is the deletion of adjacent duplicate content, of course, requires at least one character.
2, delete adjacent duplicate rows, can be converted to delete adjacent duplicate content. There is only one line break in the middle, as follows: Find (. +?) (\ r \ n) \1 replaced by $.
Note: You must not use this (. *?) (\ r \ n) \1, which will result in the absence of a newline character, why?
Because (. *?) Can match null, followed by newline, inverse reference null, replaced by empty, resulting in the line break is not.

Delete adjacent duplicate content

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.