I need a regular expression that picks up the author in the following scenarios
Letter from author to recipient regarding topic 11-10-2018
Letter from author, regarding topic 10-11-2018
I tried following the suggestions found here and this is what i have:
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)
But the console.log(author)
returns 'null'.
I am using this on Chrome as look behinds are not supported in all browsers. Any suggestions?