Quote:
Originally Posted by PatNY
\b[A-Z]\K([^\s-]+)(?=[^<>]*</text>)
The above formula continues to work perfectly in Sigil. However, when I try to use it in EditPad Pro, I get the following error message:
"Unknown regex token \K. Use backslashes to escape metacharacters."
In addition, the "\K" part of the formula is highlighted in red, so that's where the problem is.
Does anyone know how to fix this so the formula works in this editing program too?
|
The \K just resets the match so that the characters preceding it are not included in the returned match. Since in your regex, the preceding characters are a fixed length (a requirement of PCRE for each alternative in a lookbehind), I'd suggest changing that first part to a lookbehind assertion... which will achieve the same thing. I have no experience with EditPad Pro, but I assume the lookaround syntax is the same for the JGSoft regex engine as it is for Sigil's PCRE engine. Something like:
Code:
(?<=\b[A-Z])([^\s-]+)(?=[^<>]*</text>)
I'd also suggest changing the lookbehind portion to (?<=\b\p{Lu}) so that capital
unicode characters (like É or Ä) won't be excluded from the search. Making the entire new regex:
Code:
(?<=\b\p{Lu})([^\s-]+)(?=[^<>]*</text>)
I believe that should accomplish the same thing as your original expression and has (I
hope) the added benefit of working with both the JGSoft and PCRE regex engines.
EDIT: Any Replace expression you were using should remain the same. The lookbehind and lookahead assertions are not capture groups like they might appear. You still only have one capture group in your entire expression.