Does anyone have a regular expression that can accurately identify the author in these scenarios?
Letter from author to recipient regarding topic 11-10-2018
Letter from author, regarding topic 10-11-2018
I attempted to use the advice provided on this website, and this is what I came up with:
let commaRegex = new RegExp(/(?<=from) (.+?),/, 'gi','$1');
let fromToRegex = new RegExp(/(?<=from) (.+?) (?=to)/, 'gi','$1');
let combinedRegex = new RegExp(commaRegex + '|' + fromToRegex);
let author = document.getElementById('userInput').value.match(combinedRegex);
console.log(author)
However, when I run console.log(author)
, it returns 'null'.
I am aware that look behinds are not supported in all browsers, so I am using this code on Chrome. Does anyone have any other suggestions?