gpt4 book ai didi

regex - 在 Sublime Text 中按数字和空格查找和替换数字

转载 作者:行者123 更新时间:2023-12-04 22:31:09 25 4
gpt4 key购买 nike

我有很多数字,我想在它们之间添加空格,如下所示:
0123456789 --> 0 1 2 3 4 5 6 7 8 9
我正在尝试使用 Sublime Text 中的搜索和替换功能来做到这一点。到目前为止我尝试过的是使用 \S 来查找所有字符(只有数字所以没关系)和 \1\s 来替换它们。但是,这会删除数字并将它们替换为 s 。有人知道怎么做这个吗?

最佳答案

您可以使用 Lookahead and Lookbehind 的组合断言来做到这一点。使用 Ctrl + H 打开 搜索和替换 ,启用正则表达式,输入以下内容并点击全部替换

Find What: (?<=\d)(?=\d)
Replace With: empty space

Live Demo

说明 :
(?<=        # look behind to see if there is:
\d # digits (0-9)
) # end of look-behind
(?= # look ahead to see if there is:
\d # digits (0-9)
) # end of look-ahead

关于regex - 在 Sublime Text 中按数字和空格查找和替换数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24355028/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com