Python 如何在Komodo中使用replace regex?
我试图创建一个正则表达式来查找和替换txt文件中的不同名称(保持为空)。我使用科莫多,因为它是考试的一部分 下面是文本示例:Python 如何在Komodo中使用replace regex?,python,regex,komodo,Python,Regex,Komodo,我试图创建一个正则表达式来查找和替换txt文件中的不同名称(保持为空)。我使用科莫多,因为它是考试的一部分 下面是文本示例: *Cassidy: What's your name again? Chrissie Watkins: Chrissie! Cassidy: Where are we going? Chrissie: Swimming! Cassidy: Slow up, slow down! I'm not drunk! Slow down! Wait I'm coming! I'm
*Cassidy: What's your name again?
Chrissie Watkins: Chrissie!
Cassidy: Where are we going?
Chrissie: Swimming!
Cassidy: Slow up, slow down! I'm not drunk! Slow down! Wait I'm coming! I'm
coming! I'm definitely
coming! Wait, slow up! I can swim -- just can't walk or dress myself.
Chrissie: Come on in the water!
Cassidy: Take it easy. Take it easy.
Chrissie: Oh! God help me! God! Argh! God help!
Cassidy: I'm coming... I'm coming.
Chrissie: It hurts! It hurts! Oh my god! God help me! God please help!
Martin Brody: How come the sun didn't use to shine in here.
Ellen Brody: We bought the house in the fall, this is summer.
Ellen: Somebody feed the dogs, huh?
Martin: Right.
Ellen: See the kids?
Martin: They must be in the backyard.
Ellen: In Amity, you say: yahd.
必须清除文本,这意味着必须删除每行开头的所有名称(不替换任何内容)
如果我使用此选项:\w.¨:
此外,文本中的姓名(不是说话的人)也会消失/删除
是否可以只使用一个正则表达式进行清理?您可以使用
(?m)^\*?[A-Z][\w' -]*:\s*
见
详细信息
-(?m)
标志,它使re.m
匹配行的开头^
-行的开头^
-可选的\*?
字符*
-大写字母[A-Z]
-0个或多个单词字符、空格、[\w'-]*
或撇号-
-冒号:
-0+空格\s*
(?m)^\*?[A-Z][\w'-]*:\s*
,看你真棒!我不知道你的前注册码是什么意思,但我会尽力弄清楚!!我现在已经看过Wiktor演示-谢谢!!