Hi,
I have some text inside div[contenteditable="true"]
and I should highlight (span.tooLong
) part which goes over the 19 character limit. Content in div
may have HTML tags or entities and those should be ignored when counting to 19.
Twitter has similar way to highlight too long tweet:
Examples:
This is text
?This is text
This is just too long text
?This is just too lo<span class="tooLong">ng text</span>
This <b>text</b> has been <i>formatted</i> with HTML
?This <b>text</b> has been <span class="tooLong"><i>formatted</i> with HTML</span>
How can I implement this in JavaScript?
(I want to use regular expressions as much as possible)
See Question&Answers more detail:os