Equal with Deletions

A prompt from Cassidy Williams' newsletter : "Given two strings n and m, return true if they are equal when both are entered into text editors. But: a # means a backspace character (deleting backwards), and a % means a delete character (deleting forwards)."

One line solution

const regex = /[A-z]#|%[A-z]/g;

const del = (str) => (str = str.replaceAll(regex, "")).match(regex) != null ? del(str) : str;

const equalWithDeletions = (n, m) => del(n) === del(m);

OK, three lines ;-)