如何在正则表达式中使用Emacs字符类?

时间:2021-06-27 21:20:52

The Emacs documentation has a section on character classes. According to the manual, [:digit:] should match any digit character. I've tried that using re-builder but they never match, even though [0-9] matches.

Emacs文档有一个关于字符类的部分。根据手册,[:digit:]应匹配任何数字字符。我尝试过使用重建器,但它们从不匹配,即使[0-9]匹配。

How do I use character classes in an Emacs regex?

如何在Emacs正则表达式中使用字符类?

1 个解决方案

#1


10  

I figured it out. The documentation is actually explicit:

我想到了。文档实际上是明确的:

Here is a table of the classes you can use in a character alternative

下面是一个可以在字符替代中使用的类的表

So [[:digit:]] is the right way to use character classes.

所以[[:digit:]]是使用字符类的正确方法。

#1


10  

I figured it out. The documentation is actually explicit:

我想到了。文档实际上是明确的:

Here is a table of the classes you can use in a character alternative

下面是一个可以在字符替代中使用的类的表

So [[:digit:]] is the right way to use character classes.

所以[[:digit:]]是使用字符类的正确方法。