I have a text file like this:
1 textA == this textA == 1.1 textB === This is textB === 2 textC == This is textC == 2.1 Texted === This is textD === 2.1.1 Text e ==== This is textE ==== What is the correct regex pattern to format the text above:
== This textA == === This textB === == This is TextC == === This is textD === I already try to perfoming it in vim:
^ \ W * - & gt; In this pattern only textA and textB changes I have to find out "." And no letters or words until the "=" sign is found. Any letters behind the "=" symbol will be removed. Thanks in advance for any answers and hints
Solution
^. \ {-} \ ze = explanation:
^. - & gt; Started with any single letter \ {-} - & gt; The mail of 0 or more of the previous atom is possible as much as possible \ ze = - & gt; Matches in any position, and sets the end of the match there: The last character is the last letter of the whole match In human terms:
"Find and replace text Started with any character and ended with the "=" sign.
< Code>:% S / ^. \ {-} \ ze = // For more information about how to design reg.exps in Vime, see : Help pattern that is in VIM IMHO The most useful sections help.
: Help: G and : help: v may also be of interest to you. For example :
: g / = / normal! 0dt = which will simulate typing on every row of 0 = one = symbol.
Comments
Post a Comment