Extracting identifying bib elements using regular expresssion mapping Pull out bib elements from other text i e bibtex detail within other text it identifies it and is able to extract the details processed later Has limitations but is quick and simple for a robust bib parser see bib example let txt Other text ignore book1 webgpu2021kenw title WebGPU Graphics and Compute API in 20 Minutes author Kenwright year 2021 isbn 979 8757615684 etc etc article WOS 000543537300007 Author Kenwright Benjamin Title There s More to Sound Than Meets the Ear Sound in Interactive Environments Journal IEEE COMPUTER GRAPHICS AND APPLICATIONS Year 2020 Volume 40 Number 4 version 1 let reg n n r n r t n r n r t n g version 2 let reg n n n g let match txt matchAll reg match Array from match console log console log Num bib entries match length for let i 0 i match length i console log bibentry match i 0 slice 0 12 console log type match i 2 console log id match i 3 console log Extends previous example but extracts sub elements from each entry Previous regex would get all the elements this would then extract the title value for each entry let oneentry book2 webgpu2021kenw title WebGPU Graphics and Compute API in 20 Minutes author Kenwright year 2021 comment Test Comment multiline Check multiline comments isbn 979 8757615684 let reg s s s n s n g let match oneentry matchAll reg match Array from match console log num items match length for let i 0 i match length i console log match i console log console log name match i 4 value match i 5 Extra check use external test bib file 12 entries const res await fetch https notebook xbdev net var scripts example bib const txt await res text const reg n n n g let entries txt matchAll reg entries Array from entries console log total bib entries entries length Get all the title values for testing for let i 0 i entries length i const entry entries i 0 Get all the titles only titles const regtitlevalue s s s n s n g let match entry matchAll regtitlevalue match Array from match console log num items match length for let k 0 k match length k let title match k 4 trim let value match k 5 if title toLowerCase title continue console log name title value value console log ready Extra check use external test bib file 12 entries const res await fetch https notebook xbdev net var scripts example bib const txt await res text Improvement to match between symbols to compensate for nested brackets special cases Only for stand alone bib files no good for extracting nested bib entries from within text const reg gm let entries txt matchAll reg entries Array from entries console log total bib entries entries length Get all the title values for testing for let i 0 i entries length i const entry entries i 0 Get all the titles only titles const regtitlevalue s s s n s n g let match entry matchAll regtitlevalue match Array from match console log num items match length for let k 0 k match length k let title match k 4 trim let value match k 5 if title toLowerCase title continue console log name title value value
test bib file 12 entries const res await fetch https notebook xbdev net var scripts example bib const txt await res text const reg n n n g let entries txt matchAll reg entries Array from entries console log total bib entries entries length Get all the title values for testing for let i 0 i entries length i const entry entries i 0 Get all the titles only titles const regtitlevalue s s s n s n g let match entry matchAll regtitlevalue match Array from match console log num items match length for let k 0 k match length k let title match k 4 trim let value match k 5 if title toLowerCase title continue console log name title value value console log ready Extra check use external test bib file 12 entries const res await fetch https notebook xbdev net var scripts example bib const txt await res text Improvement to match between symbols to compensate for nested brackets special cases Only for stand alone bib files no good for extracting nested bib entries from within text const reg gm let entries txt matchAll reg entries Array from entries console log total bib entries entries length Get all the title values for testing for let i 0 i entries length i const entry entries i 0 Get all the titles only titles const regtitlevalue s s s n s n g let match entry matchAll regtitlevalue match Array from match console log num items match length for let k 0 k match length k let title match k 4 trim let value match k 5 if title toLowerCase title continue console log name title value value