Quick actions

cmd+k|ctrl+k

Navigation

Languages

Untitled

Snippet info

Language

Nim

Visibility

unlisted

Author

legacy-anonymous

Created

2017-06-15T13:43:13Z

Updated

2017-06-15T13:43:13Z

import strscans

const input = "1|2.5|51.3|4,2|3.41|5.2|3,"

var x, y: int
var a, b: float

var startIndex: int = 0
for i in low(input)..high(input):
  if input[i] == ',':
    if scanf(input[startIndex..i], "$i|$f|$f|$i", x, a, b, y):
      echo "Got Match!"
      echo "x: ", x, "; y: ", y, "; a:", a, "; b: ", b
      echo ""
    else:
      echo "Match failed against: ", input[startIndex..i]
    
    startIndex = i + 1
INFO