ag Silver Searcher: rules for lookahead/lookbehind patterns?

前端 未结 1 730
孤城傲影
孤城傲影 2021-02-05 04:04

I\'m using ag in Vim with good results for string/file search.

However, there seems to be not much documentation how patterns are constructed for ag.

<
1条回答
  •  误落风尘
    2021-02-05 04:41

    The Silver Searcher tool uses PCRE (Perl-Compatible Regular Expression) syntax. So instead of Vim's \ze, you need to use the Perl syntax for positive lookahead: (?=pattern). (The corresponding lookbehind for \zs would be (?<=pattern).)

    I'm showing your example on the command-line, but it should be identical from within Vim:

    $ ag 'Pragmatic(?= Vim)'
    

    0 讨论(0)
提交回复
热议问题