fork download
  1. object Main {
  2. def main(args: Array[String]): Unit = {
  3. val rex = "([^%]++|%[diouxXcs%])".r
  4. val test = "The annual %% rate is %d% %."
  5. val matches = rex.findAllMatchIn(test).toList
  6. for ((a, b) <- matches zip matches.tail) {
  7. if (a.end < b.start) {
  8. println(test)
  9. println(" " * a.end + "^")
  10. }
  11. }
  12. }
  13. }
  14.  
Success #stdin #stdout 0.41s 321920KB
stdin
Standard input is empty
stdout
The annual %% rate is %d% %.
                        ^
The annual %% rate is %d% %.
                          ^