中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-13 22:40
47,812 topics / 349,916 posts / today 0 new / 48,268 members
论坛回收站 » Another tricky problem encountered, specifically asking experts for advice.
Printable Version  7,392 / 1
Floor1 qianxu Posted 2011-01-24 08:25
新手上路 Posts 17 Credits 17
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.
Floor2 glodboy Posted 2011-01-24 11:53
新手上路 Posts 11 Credits 10
This is too complicated. I don't remember being able to delete symbols in specified lines with P, but replacing might be possible.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023