『楼 主』:
又碰到一个棘手的问题,特别向高手请教。
使用 LLM 解释/回答一下
现在,本人又碰到一个棘手的问题,特别向高手请教。
就是需要首先判断一下,各行文本中“前n个相同且连续的字符”到底是不是我想要删除的那些特定字符,如果“前n个相同且连续的字符”是我指定的那些字符就删除“前n个相同且连续的字符”,但不是删除该行。
我只想删除各行文本中“前n个相同且连续的字符”含有特殊字符“#”和“?”和“@”的字符本身删除,即使本行当中其它位置也有该字符,也不用管它了,只删除“前n个相同且连续的”有条件指定的字符即可。
例如: 在1.txt 中
#############abcdefgh#1666666@
#######1234??5##
???????????????????????????6789
????????????????????11111112222?55555?
@@@@@@@@6666#777?88888@9999#
说明:我就是想删除以上五行前面的“前n个相同且连续的字符”
即,删除第一行中的前#############,而保留abcdefgh#1666666@
删除第二行中的前#######,而保留1234??5##
删除第三行中的前???????????????????????????,而保留6789
删除第四行中的前????????????????????,而保留11111112222?55555?
删除第五行中的前@@@@@@@@,而保留6666#777?88888@9999#
最终我想要达到的效果是 保存在 2.txt
abcdefgh#1666666@
1234??5##
6789
11111112222?55555?
6666#777?88888@9999#
在这里先谢谢各位老师了。 并在此新年之际,祝各位老师快乐。
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.
|