Skip to content

Instantly share code, notes, and snippets.

@nichtich
Created August 11, 2020 07:11
Embed
What would you like to do?
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