Search with REGEX in the VI

1

I have a regex that is valid as per the test link , but in the vi it does not work:

2017\/04\/26 12:24:(.*)(89418644)

Here is an example that this REGEX should get married:

INFO | 2017/04/26 12: 24: 15,019 | [OrderEntryAvailableOutgoingFlowListPopulator] 89418644 OK

I think it's some syntax rule for using groups in vi search, but I still can not identify.

    
asked by anonymous 26.04.2017 / 17:42

1 answer

2

When you perform a search on vi it does not interpret directly that what you are using is a REGEX, so that what it actually searches for is String .

So you should use the same log when passing a String to REGEX, and you need to escape the special characters.

2017\/04\/26 12:24:\(.*\)\(89418644\)

Addendum

If you are just searching you could simply remove the groups:

2017\/04\/26 12:24:.*89418644

If you are working with replace with a modifier that assists in this \v :

:%s/\v2017\/04\/26 12:24:(.*)(89418644)/REPLACE/

Source Vim Regex Capture Groups

    
26.04.2017 / 19:32