Right Align - cpmcgrath/codealignment GitHub Wiki
Let's say you have a list of numbers...
51351
12
13
8183
We want to align them by the so the ones line up, tens line up, etc. We can use the special groups insert and compare for this...
\d+ //Find consecutive digits
\d+(?<compare>) //Find consecutive digits, but compare their end position
(?<insert>\d+)(?<compare>) //Find consecutive digits, compare their end position, but insert spaces at the start.
This will also work if you want to align numbers with decimal places.
We can also use similar logic to right align the next word...
\s+(?<x>[^\s]) //Align by space
\s+(?<insert>[^\s]) //Insert at the same location
\s+(?<insert>[^\s]+)(?<compare>) //And compare at the end of the word.