Skip to content

Instantly share code, notes, and snippets.

@JoSSte
Created May 10, 2022 14:51
Show Gist options
  • Save JoSSte/54a5ec5605f92e5ed08931e25b27cfc4 to your computer and use it in GitHub Desktop.
Save JoSSte/54a5ec5605f92e5ed08931e25b27cfc4 to your computer and use it in GitHub Desktop.
DMI weather units regex

Regular expression to parse DMI's API Unit confluence page into json

Regex

([a-z0-9_\*]*)\t([a-zA-Z\/°²\-\%]*)\t(.+)\t(.+)\t[X]{0,1}\t[X]{0,1}

If testing at https://regexr.com/ use /gm

/^([a-z0-9_\*]*)\t([a-zA-Z\/°²\-\%]*)\t(.+)\t(.+)\t[X]{0,1}\t[X]{0,1}$/gm

Replace with

{"label":"\1","unit":"\2","description":"\3"},

(remove the last coma, and surround with [ ] )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment