我想把数字和另一个字符分开。你知道吗
示例
输入:
we spend 100year
输出:
we speed 100 year
输入:
today i'm200 pound
输出
today i'm 200 pound
输入:
he maybe have212cm
输出:
he maybe have 212 cm
我试过re.sub(r'(?<=\S)\d', ' \d', string)
和re.sub(r'\d(?=\S)', '\d ', string)
,但都没用。你知道吗
Tags:
这样就可以了:
印刷品:
同一行文本中多个匹配项的相同语法:
捕获组(通常)从左到右编号,
\number
表示匹配中的每个编号组:如果更容易阅读,您可以命名捕获组,而不是使用
\1 \2
表示法:这需要处理一个案例:
这会照顾到另一个:
希望有人有更多的regex经验比我能想出如何结合他们。。。你知道吗
相关问题 更多 >
编程相关推荐