Search with REGEX in VI

Asked

Viewed 203 times

1

I have a regex that is valid according to the test site https://regex101.com/ , but in the vi she does not work:

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

Follow an example that this REGEX should marry:

INFO| 2017/04/26 12:24:15.019 | [Orderentryavailableoutgoingflowlistpopulator] 89418644 OK

I believe it’s some syntax rule for using groups in the vi search, but I haven’t been able to identify.

  • "vi" would be the command line text editor? It has an example of the text you are looking for?

  • I edited the question by adding the text that REGEX should locate.

1 answer

2


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

So you should use the same logic when passing a String to REGEX, and it is necessary to escape the special characters.

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

Addendum

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

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

If Voce is working with replace a modifier that assists in this \v :

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

Source I came Regex Capture Groups

Browser other questions tagged

You are not signed in. Login or sign up in order to post.