giovedì 22 maggio 2014
formatTextInColumns.groovy
just made a small #groovylang gist to format text with elements separated by char/string to fixed column:https:/:
https://gist.github.com/bartoleo/aab5ad2a8164eeae527b
example:
println "example1 without separators"
println formatTextInColumns("""\
aaa|bbbb|ccc
d|e|f|g
h|iiiiiiiiiii
jjjjjjj
end""","|",false)
println "example2 with separators"
println formatTextInColumns("""\
aaa|bbbb|ccc
d|e|f|g
h|iiiiiiiiiii
jjjjjjj
end""","|",true)
output:
example1 without separators
aaa bbbb ccc
d e f g
h iiiiiiiiiii
jjjjjjj
end
example2 with separators
aaa |bbbb |ccc|
d |e |f |g|
h |iiiiiiiiiii|
jjjjjjj|
|
end |
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento