You're viewing a comment by Nick Shyrokovskiy and its responses.

Nick Shyrokovskiy Permalink
July 07, 2012, 16:24

Hi. I think there is a little mistake in explaining item
"70. Delete duplicate, nonconsecutive lines from a file."

Namely you state that introducing double \n is to suppress greadyness of [ -~]*\n but gready part is [ -~]* and it just can't eat \n that follows it, so one \n is enough.

The purpose of double \n i think is to handle to both cases
1. repeated line is in front of the hold buffer
2. repeated line is somewhere in the middle of the hold buffer

Say you don't double and write(extended regexp):


Looks good, but it would work only in 2 case(middle or end)
and not in 1 case(begin) as \n would stay unmatched.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "disk_124": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.