确定系统提供的正则表达式库

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 无关。

所以,问题是:

  1. 我如何确定我的系统less将使用哪个正则表达式库?
  2. 我的系统提供正则表达式库意味着什么?
  3. 这个提供的正则表达式库会影响哪些其他实用程序和程序?
  4. 如果您提到系统可能/正在使用的任何特定正则表达式库,请尽可能提供指向该正则表达式库页面的链接。

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)

Ste*_*itt 6

  1. 如果您指的是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)。

  2. 我认为该表达式指的是系统less上可用的任何库auto,至少在选项的上下文中。构建后,给定的less二进制文件不会更改其正则表达式实现。

  3. 没有任何。

支持的库有:

  • POSIXregcomp(在版本字符串中标识为“POSIX”);
  • PCRE(“PCRE”);
  • GNU C 库re_compile_pattern(“GNU”);
  • regcmp (“V8”);
  • Unix V8 regcomp,由系统提供或less自己的副本(Henry Spencer 的实现;“Spencer V8”);
  • re_comp (“BSD”)。