Now, I have another tricky problem and specifically ask for help from experts.
That is, first, I need to judge whether the "first n identical and consecutive characters" in each line of text are exactly those specific characters I want to delete. If the "first n identical and consecutive characters" are the specified characters, then delete the "first n identical and consecutive characters", but do not delete the entire line.
I just want to delete the characters themselves whose "first n identical and consecutive characters" contain special characters "#" and "?" and "@". Even if there are such characters in other positions in this line, it doesn't matter. Only the "first n identical and consecutive" specified characters need to be deleted.
For example: In 1.txt
#############abcdefgh#1666666@
#######1234??5##
???????????????????????????6789
????????????????????11111112222?55555?
@@@@@@@@6666#777?88888@9999#
Explanation: I just want to delete the "first n identical and consecutive characters" at the front of the above five lines.
That is, delete the first ############# in the first line, and keep abcdefgh#1666666@
Delete the first ####### in the second line, and keep 1234??5##
Delete the first ??????????????????????????? in the third line, and keep 6789
Delete the first ???????????????????? in the fourth line, and keep 11111112222?55555?
Delete the first @@@@@@@@ in the fifth line, and keep 6666#777?88888@9999#
The final effect I want to achieve is to be saved in 2.txt
abcdefgh#1666666@
1234??5##
6789
11111112222?55555?
6666#777?88888@9999#
Thank you all teachers here first. And on this New Year's Day, I wish all teachers happiness.
That is, first, I need to judge whether the "first n identical and consecutive characters" in each line of text are exactly those specific characters I want to delete. If the "first n identical and consecutive characters" are the specified characters, then delete the "first n identical and consecutive characters", but do not delete the entire line.
I just want to delete the characters themselves whose "first n identical and consecutive characters" contain special characters "#" and "?" and "@". Even if there are such characters in other positions in this line, it doesn't matter. Only the "first n identical and consecutive" specified characters need to be deleted.
For example: In 1.txt
#############abcdefgh#1666666@
#######1234??5##
???????????????????????????6789
????????????????????11111112222?55555?
@@@@@@@@6666#777?88888@9999#
Explanation: I just want to delete the "first n identical and consecutive characters" at the front of the above five lines.
That is, delete the first ############# in the first line, and keep abcdefgh#1666666@
Delete the first ####### in the second line, and keep 1234??5##
Delete the first ??????????????????????????? in the third line, and keep 6789
Delete the first ???????????????????? in the fourth line, and keep 11111112222?55555?
Delete the first @@@@@@@@ in the fifth line, and keep 6666#777?88888@9999#
The final effect I want to achieve is to be saved in 2.txt
abcdefgh#1666666@
1234??5##
6789
11111112222?55555?
6666#777?88888@9999#
Thank you all teachers here first. And on this New Year's Day, I wish all teachers happiness.
