I have the following RegExp: (?<= )L.*(?!MH$).
The idea is:
(?<= )4 spaces must precede the match, but not be included in the match.L.*The match must begin withLand include the rest of the string ...(?!MH$)UNLESSMHis at the end of the string.
This last condition is being ignored. The string ending with MH still matches. Why?
const regExpStr = String.raw`(?<= )L.*(?!MH$)`;
const regExp = new RegExp(regExpStr);
const str = '2. L2 B4 RHODA 1 ADDN,SOMECITY,OK,74999 - 81 HILLCREST MH';
const match = str.match(regExp)?.[0];
console.log(match);