Exception:A highlighting span matched 0 characters, which would cause an endless loop. Change the highlighting definition so that either the start or the end regex matches at least one character. Start regex: (?<=(?<=([^\\]|^)(\\\\)*)~\|)(?!.*(?<=([^\\]|^)(\\\\)*)~\|\|\|) End regex: ($|$ )