align by common substring by rolf

package main
import "os"
import "fmt"
import "bufio"
import "strings"
func main(){
 r:=bufio.NewReader(os.Stdin);a:="";
 for{
  fmt.Print(a);b,e:=r.ReadString('\n');
  if e!=nil{break}
  j:=0;
  for i:=0;i<55&&j<1;i++{j=strings.Index(a,b[i:i+9])-i}
  for i:=0;i<j;i++{b=" "+b}
  a=b
 }
}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page