Vim positive lookahead regex

后端 未结 1 757
迷失自我
迷失自我 2020-12-05 01:55

I am still not so used to the vim regex syntax. I have this code:

rename_column :keywords, :textline_two_id_4, :textline_two_id_4

I would l

相关标签:
1条回答
  • 2020-12-05 02:09

    If you check the vim help, there is not much to explain: (:h \@=)

    \@=     Matches the preceding atom with zero width. {not in Vi}
            Like "(?=pattern)" in Perl.
            Example             matches
            foo\(bar\)\@=       "foo" in "foobar"
            foo\(bar\)\@=foo    nothing
    

    This should match the last id:

    /id\(_\d$\)\@=
    

    save some back slashes with "very magic":

    /\vid(_\d$)@=
    

    actually, it looks more straightforward to use vim's \zs \ze:

    id\ze_\d$
    
    0 讨论(0)
提交回复
热议问题