Uses regex instead of substr
Fixes formatting
Solved #24 in scala
Solves #24 with less (but slower) code