Hacker News new | ask | show | jobs
by draegtun 1569 days ago
I like using `parse` in Rebol / Red - http://www.rebol.com/r3/docs/functions/parse.html

Here's the parse rule for Batman:

  [
      16 "na"
      2 [space "batman"]
  ]
And complete example for the Semantic version:

    digit: charset "1234567890"

    if parse "0.2.5" [
        opt "v"
        copy major [some digit]
        "."
        copy minor [some digit]
        "."
        copy patch [some digit]
    ][
        print [major minor patch]
    ]