Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function parseTranscription(str) {
- const regex = /(AI|User):/g;
- const parts = str.split(regex).filter(part => part.trim() !== '');
- // Преобразуем части в массив объектов
- const messages = [];
- for (let i = 0; i < parts.length; i += 2) {
- messages.push({
- sender: parts[i].trim(),
- message: parts[i + 1].trim()
- });
- }
- return messages;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement