Ung*_*uer 6 libraries regular-expression
我试图在less
昨天使用以下正则表达式:
^\+1[[:space:]]*$
,它在grep
. 这在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.
The search starts at the first line displayed (but see the -a and -j options, which change this).
Run Code Online (Sandbox Code Playgroud)
我在 中提出了这个问题/dev/chat
,对于使用什么库,甚至选择库的优先级,(对我而言)没有太多共识,更不用说实际检查当前使用的内容的方法了。我目前使用 Fedora 30,但希望答案与 Linux 无关。
所以,问题是:
less
将使用哪个正则表达式库?ldd
显示
[unge@localhost ~]$ ldd "$(command -v less)"
linux-vdso.so.1 (0x00007fff040e0000)
libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007f6733339000)
libc.so.6 => /lib64/libc.so.6 (0x00007f6733173000)
/lib64/ld-linux-x86-64.so.2 (0x00007f67333be000)
Run Code Online (Sandbox Code Playgroud)
如果您指的是less
二进制文件,less --version
则会告诉您它使用的是哪个正则表达式实现;例如
$ less --version
less 487 (GNU regular expressions)
Copyright (C) 1984-2016 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less
Run Code Online (Sandbox Code Playgroud)
在构建时,库由--with-regex
给定给./configure
:
--with-regex=LIB select regular expression library (LIB is one of auto,none,gnu,pcre,posix,regcmp,re_comp,regcomp,regcomp-local) [auto]
Run Code Online (Sandbox Code Playgroud)
并在构建日志中进行跟踪。
一些实现可作为单独的库(pcre
例如)使用,其他实现包含在 C 库中(gnu
例如),其中之一包含在less
源代码中 ( regcomp-local
)。
我认为该表达式指的是系统less
上可用的任何库auto
,至少在选项的上下文中。构建后,给定的less
二进制文件不会更改其正则表达式实现。
没有任何。
支持的库有:
regcomp
(在版本字符串中标识为“POSIX”);re_compile_pattern
(“GNU”);regcmp
(“V8”);regcomp
,由系统提供或less
自己的副本(Henry Spencer 的实现;“Spencer V8”);re_comp
(“BSD”)。