import re
def foo(input_st, keep_st):
parts = input_st.split(keep_st)
clean_parts = [re.sub("[a-z]*", "", part) for part in parts]
return keep_st.join(clean_parts)
def munge(text, match):
prefix, match, suffix = text.partition(match)
prefix = "".join(c for c in prefix if not c.islower())
suffix = "".join(c for c in suffix if not c.islower())
return prefix + match + suffix
其他使用分区模块的方法似乎没有考虑到触发器字的重复。这个例子在你有“aBcJohnsonDeFJohnsonHiJkL”的情况下是有效的,在这种情况下,这个特殊的情况是你关心的。在
^{} 您的朋友在这里:
示例用法:
^{pr2}$可以对字符串进行分区,检查是否有分隔符,然后翻译出小写字母,例如:
相关问题 更多 >
编程相关推荐