Quantcast
Channel: CodeProject Latest postings for Regular Expressions
Viewing all articles
Browse latest Browse all 224

Regex search to find and remove consecutive lines which end with same characters

$
0
0
Hello,
I need to write a regular expression search which will locate when a line ends with the same text as the preceding line, but does not have the same first 10 characters. So in this example:

[11:12:21] Hello this is Tom. How are you?
[11:14:08] Hello this is Tom. How are you?

. . . I would need to search for consecutive lines for which the text was the same after the time entered in brackets.

I know that this search:

FIND: ^.{11}(.*)$
REPLACE; $1

. . . will locate the first 11 characters and remove them.

This search:

FIND: ^((.{10}).*)(?:\r?\n\2.*)+
REPLACE: $1

. . . will locate lines where the first 10 characters are the same and remove them.

But I can't figure out how to structure the search so it checks the text from position 11 to the end of the line, and then checks if the text on the next line from the 11th character to the end of the line is the same.

Viewing all articles
Browse latest Browse all 224

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>