document.getElementById('inputfile')
.addEventListener('change', function () {
let fr = new FileReader();
fr.onload = function () {
text = fr.result;
// Text mit dem vCard-Parser auswerten,
// dann stehen die Werte im Objekt parsed zur Verfügung:
const
parsed = vCardParser.parse(fr.result);
console.log(parsed);
const
item = parsed[0],
postBox = item.address[0].value.postOfficeBox,
streetNr = item.address[0].value.street.replace('\\n', ' '),
city = item.address[0].value.city,
postalCode = item.address[0].value.postalCode,
regex = /^([^\d]+) +(\d+[a-zA-Z]*)$/,
matches = streetNr.match(regex);
if (matches) {
const
street = matches[1],
nr = matches[2];
console.log(`postBox: ${postBox}, streetNr: ${streetNr}, street: ${street}, nr: ${nr}`);
} else {
console.log(`street and number don't match pattern: ${streetNr}`);
}
// Beispiel: Angezeigten Namen in Eingabefeld eintragen:
document.getElementById('display-name').value = parsed[0].displayName;
}
fr.readAsText(this.files[0]);
});