Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const lines = e.target.result.split('\n').map(line => line.trim()).filter(line => line !== '');
- const output = [];
- const regex = /^(.+?) ?: (.+?) \/ (.+?)\. - (.+?) ?: (.+?), (\d{4})\. - (.+)$/;
- lines.forEach((line, index) => {
- const match = line.match(regex);
- if (match) {
- const [
- _,
- title, // 0-24 h
- subtitle, // Поеми
- author, // Недялко Славов
- place, // Пловдив
- publisher, // Страница
- year, // 2003
- pages // 95 с.
- ] = match.map(m => m.trim());
- output.push(
- `Record ${index + 1}:\n` +
- `245 $a: ${title}\n` +
- `245 $b: ${subtitle}\n` +
- `245 $c: ${author}\n` +
- `260 $a: ${place}\n` +
- `260 $b: ${publisher}\n` +
- `260 $c: ${year}\n` +
- `300 $a: ${pages}\n`
- );
- } else {
- output.push(`Record ${index + 1}: Failed to parse: "${line}"\n`);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement