Cod*_*ich 22 less regular-expression
在哪里可以找到less
正则表达式搜索模式的参考?
我想用less
using\d
查找数字来搜索文件,但它似乎不理解这个通配符。我试图找到less
正则表达式模式的参考,但在手册页和 Internet 上找不到任何内容。
ilk*_*chu 24
less
的手册页说:
/pattern
Search forward in the file for the N-th line containing
the pattern. N defaults to 1. The pattern is a regular
expression, as recognized by the regular expression library
supplied by your system.
Run Code Online (Sandbox Code Playgroud)
因此接受的语法可能取决于您的系统。顺便说一句,它似乎在我的 Debian 系统上接受扩展的正则表达式,请参阅regex(7)
和为什么我的正则表达式在 X 中有效但在 Y 中无效?
\d
来自 Perl,并非所有正则表达式引擎都支持。使用[0-9]
或[[:digit:]]
匹配数字。(它们的确切行为可能取决于语言环境。)
Kus*_*nda 12
支持的表达式less
记录在re_format(7)
手册 ( man 7 re_format
) 中。该手册描述了系统上可用的扩展正则表达式和基本正则表达式。该less
实用程序理解扩展的正则表达式。
要匹配数字,您可以使用[0-9]
or [[:digit:]]
(前者略有不同,因为前者取决于当前的语言环境)。该\d
模式是类似 Perl 的正则表达式 (PCRE),不受less
.
归档时间: |
|
查看次数: |
16776 次 |
最近记录: |