Using positive lookbehind in Movable Type templates causes error due to < in pattern string

53 views Asked by At

I'm attempting to limit the length of a displayed string to the first 50 characters plus any needed to end at the next word boundary. I'm using the regex_replace filter in the template tag to replace all the characters after the pattern match with "...". However, using the positive lookbehind requires the less-than symbol which apparently MT is interpreting as the start of a tag. This is causing nearby tags to break and the template fails to publish, reporting an error. It there any way to incorporate the positive lookbehind into the template?

<mt:Ignore>Limit entryTitle length by discarding any/all chars after whole word containing 50th char</mt:Ignore>
<mt:entryTitle regex_replace="/((?<=.{50}\b).+)/i","...">
1

There are 1 answers

2
Bohemian On

This is an XML problem: The "<" character is illegal within a tag. Encode it as &lt;:

<mt:entryTitle regex_replace="/((?&lt;=.{50}\b).+)/i","...">