Attempting to utilize the "exec" method in RegExp, I have written the following code:
let result = <RegExpExecArray>{};
while (result = expressionCheck.exec(text)) {
let matchIndex = result.index;
let t = result[0].length;
matchRanges.push(new RegRange(matchIndex, t));
}
However, an error is being thrown stating:
Build:Type 'RegExpExecArray | null' is not assignable to type 'RegExpExecArray'.
I attempted to modify the loop condition to :
while ((result = expressionCheck.exec(text)) != null) {
Even after this adjustment, it continues to not work. How should the loop condition be written for this scenario?