如何使用正则表达式在 Vim 中的任何数字后跟一个点后附加一个字符?
How to append a character after any number followed by a dot in Vim using regex?
我想在 Vim 中使用正则表达式在任何数字后跟一个点后附加一个字符。
示例(附加 -):
1. Contrary to popular belief, Lorem Ipsum is not simply random text.
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
4022. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
变为:
1.- Contrary to popular belief, Lorem Ipsum is not simply random text.
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
4022.- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
请帮忙。
:%s/\(\d\.\)/-/g
它改变了这个:
1. this 2. will
3_ do 4305. what 5.. you
ask 6*
对此:
1.- this 2.- will
3_ do 4305.- what 5.-. you
ask 6*
它的工作方式是匹配并记住任何数字 \d
后跟一个点 \.
(\(
和 \)
之间的东西被记住以备后用 - 这些被称为
捕获组)。然后使用 </code> 将其替换为记住的捕获组
并添加一个 <code>-
。最后的 g
使每一行的每场比赛都发生。
我想在 Vim 中使用正则表达式在任何数字后跟一个点后附加一个字符。
示例(附加 -):
1. Contrary to popular belief, Lorem Ipsum is not simply random text.
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
4022. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
变为:
1.- Contrary to popular belief, Lorem Ipsum is not simply random text.
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
4022.- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
请帮忙。
:%s/\(\d\.\)/-/g
它改变了这个:
1. this 2. will
3_ do 4305. what 5.. you
ask 6*
对此:
1.- this 2.- will
3_ do 4305.- what 5.-. you
ask 6*
它的工作方式是匹配并记住任何数字 \d
后跟一个点 \.
(\(
和 \)
之间的东西被记住以备后用 - 这些被称为
捕获组)。然后使用 </code> 将其替换为记住的捕获组
并添加一个 <code>-
。最后的 g
使每一行的每场比赛都发生。