如何在Vim中搜索,使用正则表达式来表示字母(ascii和非ascii)?

时间:2021-10-26 10:16:00

In .NET, \p{L} matches any ascii or non-ascii letter (so it will match both a and ü).

在.NET中,\ p {L}匹配任何ascii或非ascii字母(因此它将匹配a和ü)。

http://www.regular-expressions.info/unicode.html#prop

http://www.regular-expressions.info/unicode.html#prop

Is there a Vim equivalent for this?

Vim是否相当于此?

In Vim \a or \w will only match characters in range [a-z] (or [0-9A-Za-z_]).

在Vim \ a或\ w中,它只匹配范围[a-z](或[0-9A-Za-z_])中的字符。

1 个解决方案

#1


6  

You can explicitly tell vim which ranges of hex values to match. This is kind of a shotgun approach, but if you know what the possible ranges (like UTF-8 for example) this would work:

您可以明确告诉vim要匹配的十六进制值范围。这是一种霰弹枪方法,但是如果你知道可能的范围(例如UTF-8),这将起作用:

/[\x7f-\xffa-zA-Z]

You can also search for explicit unicode values by entering in the unicode character directly or it's code in the following format:

您还可以通过直接输入unicode字符或以下列格式输入代码来搜索显式unicode值:

/\%u0300

#1


6  

You can explicitly tell vim which ranges of hex values to match. This is kind of a shotgun approach, but if you know what the possible ranges (like UTF-8 for example) this would work:

您可以明确告诉vim要匹配的十六进制值范围。这是一种霰弹枪方法,但是如果你知道可能的范围(例如UTF-8),这将起作用:

/[\x7f-\xffa-zA-Z]

You can also search for explicit unicode values by entering in the unicode character directly or it's code in the following format:

您还可以通过直接输入unicode字符或以下列格式输入代码来搜索显式unicode值:

/\%u0300