I have this structure, and i want to extract only FN
and TEL
:
BEGIN:VCARD
VERSION:2.1
N:Pepe;Perez;;;
FN:Pepe Perez
TEL;HOME:+549465738283
END:VCARD
BEGIN:VCARD
VERSION:2.1
N:Jose;Perez;;;
FN:Jose Perez
TEL;CELL:+549465738284
END:VCARD
Like:
[
{name: 'Pepe perez', tel: '+549465738283'},
{name: 'Jose perez', tel: '+549465738284'}
]
I have this code:
var file = fs.readFileSync('app/vcards/00003.vcf', 'utf-8');
var p = new RegExp(/(^FN:)(.*)(\n)(TEL;)(.*:)(\+)([0-9]+)/g);
console.log(p.exec(file));
But result is null
Anybody help me?
It's not really regex, but on request here's a way to manually parse vCard, as I believe that's the easiest to keep track of and modify
It should also be noted that there is middleware available for this as well
https://www.npmjs.com/package/vcard
it does basically the same thing, splits the lines and looks for
BEGIN
andEND
to get each card etc.