Given two strings s1 and s2, I am trying to write a regex that will match a string that starts with s1 but does not end with s2
s1
s2
You can use startsWith and endsWith
startsWith
endsWith
let arr = [`TEST-101`, `TEST-SOME-DESC`,`TEST-101-BAD`,`TEST-SOME-DESC-BAD`] arr.forEach(e=>{ console.log(e, e.startsWith('TEST') && !e.endsWith('BAD')) })