Created
August 11, 2020 07:11
-
-
Save nichtich/1d08e5a2ce7ff0c9a276290463799618 to your computer and use it in GitHub Desktop.
PICA Plain parser in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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