Detect words or any character after some matching pattern, regular expression pattern (Vim)

I have a text file with the following image:

1 textA == this is textA ==
1.1 textB === this is textB ===
2 textC == this is textC ==
2.1 textD === this is textD ===
2.1.1 textE ==== this is textE ====

What is the correct regex pattern for formatting the text above:

== this is textA ==
=== this is textB ===
== this is textC ==
=== this is textD ===

I'm already trying to do this in vim:

^\w* -> this pattern just changes only textA and textB

I need to discover "." and any character or words until you meet the = sign. Any characters behind the "=" sign will be deleted. Thanks in advance for any answers and pointers.

<h / "> Solution

^.\{-}\ze=

Explanation:

^.   -> started with any single character
\{-} -> matches 0 or more of the preceding atom, as few as possible
\ze= -> Matches at any position, and sets the end of the match there: The previous char  is the last char of the whole match

In human words:
"Find and replace text starting with any single character, followed by something, and ending with the" = "sign.

+3
1
:%s/^.\{-}\ze=//

, reg.exps Vim, . :help pattern, Vim IMHO.

:help :g :help :v . , :

:g/=/normal! 0dt=

, 0dt = , =.

+4

Source: https://habr.com/ru/post/1766622/


All Articles