Skip to content

Instantly share code, notes, and snippets.

@nichtich
Created August 11, 2020 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nichtich/1d08e5a2ce7ff0c9a276290463799618 to your computer and use it in GitHub Desktop.
Save nichtich/1d08e5a2ce7ff0c9a276290463799618 to your computer and use it in GitHub Desktop.
PICA Plain parser in JavaScript
/* PICA Plain parser in JavaScript */
const pp=s=>s.split(/\n/)
.map(l=>l.match(/^([012][0-9][0-9][A-Z@])(\/([0-9]{2,3}))?\s*(\$([A-Za-z0-9]).+)+/)
.filter(m=>m)
.map(m=>[m[0],m[2],...m[3].split(/\$([A-Za-z0-9])/).slice(1).map(s=>s.replace(/\$\$/g,'$'))])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment