I'm trying to get the letters between two specified symbols.
Example
var a = 'Testing code https://example.com/ABC-BAC tralala'; // I would need to get ABC
var b = 'Depends on x \n https://example.com/CADER-BAC'; // I would need to get CADER
var c ='lots of examples: \n example.com/CAB-BAC'; // I would need to get CAB
var d ='lots of examples: \n https://abc.example.com/CAB-BAC'; // I would need to get CAB
My main problem is that I need a unique syntax that would work for both https:// version or without any https://, therefore using indexOf on '/' wouldn't work that well.
I've tried regex but of course, that only fits one solution:
let regex = /^https://example\.com/[a-zA-Z]+-BAC$/i;
return regex.test(input);
Any help is appreciated, thank you!