I have a sequence of numbers as shown below. I want to combine the numbers into a group of 4. Can someone give a vim regex for this?
Entrance: 1234 56 7890 1234
The output should be: 1234 5678 9012 34
Two passes:
s/ //g s/\(.\{4\}\)/\1 /g
I would do this in two steps: (1) remove spaces to the right of groups of numbers
:s/\(\d\+\) /\1/g
(2) grouping:
:s/\(\d\{4}\)/\1 /g
In the case where many lines record a macro or follow these steps for the marked area.
, :
:s/\(\d\) *\(\d\) *\(\d\) *\(\d\) */\1\2\3\4 /g
, asinine. , 2 Monsteregex β’, . , .
:s/\(\d\)\s*\(\d\)\s*\(\d\)\s*\(\d\)\s*/\1\2\3\4 /g
, .
Source: https://habr.com/ru/post/1709082/More articles:Eclipse RCP: how to observe the status of cut / copy / paste commands? - eclipseHow to combine two FORs into one - javaWhat is a mature program? - language-designHow to find out if the application restarted after a phone call? - iphoneDivide a square into small squares - mathWhat is the easiest way to find a join model, given two objects when using has_many: via - ruby-on-railsCS0016: Invalid directory error - securityPerhaps: a program that executes Qt3 and Qt4 code? - c ++How can I connect the IBAction method to a simple view for a touch event? - iphoneWhy does Internet Explorer close after debugging my web application using VS2008? - debuggingAll Articles