Regex / macro to align columns
Posted: Thu Oct 16, 2014 10:37 pm
Given 3 columns of whitespaced delimited words with uneven spacing, I would like to align the columns:
I have:
I would like:
I would like to use search and replace with regular expressions. The shortest way I could think of is to search and replace in two passes.:
First replace:
I have:
Code: Select all
xxxxxxxxx AS yyyyyyyyyyyyyyyy
x AS yyy
xxxx AS yyCode: Select all
xxxxxxxxx AS yyyyyyyyyyyyyyyy
x AS yyy
xxxx AS yyFirst replace:
- [[:blank:]]+
- <blank repeated the number of times as long as the first string>
- Regular expression box checked
- ^(.{9})[[:s:]]+([^[:s:]]+)[[:s:]]+([^[:s:]]+)$
- \1 \2 \3
- Regular expression box checked
- For the first replace, instead of hitting the spacebar x times I would like to be able to specify the repeat number in code something like: <space>{9}
- For the first and second replace I would like to prompt the user for the length of the string instead of hard-coding the number (in this case 9).
- It would be great if the above two steps could be combined into one.