我有任务
"Turn character that is single into '(' and character that are repeated into ')'
for Example "TAAreTheBest" into ")))())()()()"
从上面看,转为“)”的字符是T,A,E
So key is I want to use REGEX to find out which characters is repeated and replace it with ')'
这些都是我以前尝试过的代码,但对我不起作用
(\w)\1*
([a-zA-Z])\1*
\w{2,}
我对python很陌生。我想了解更多关于正则表达式的知识,所以我认为这个任务可以使用正则表达式来解决它。所以请帮帮我。非常感谢。在
我希望这不是从一开始就做的
sub
相关问题 更多 >
编程相关推荐