Hi...! I have a text file patterned like this :
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 ====
Whats the right regex pattern to formatting the text above:
== this is textA ==
=== this is textB ===
== this is textC ==
=== this is textD ===
I already try to perfoming this in vim :
^\w* -> this pattern just changes only textA and textB
I need to detect "." and any character or words until meet the "=" sign. Any characters behind the "=" sign will be deleted. Thanks in advance for any answers and pointers.
The answers
^.\{-}\ze=
The 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 it can be said like :
"Found a text which started with any single character followed by anything and ended with "=" sign. And replace it !