#552·regexr

Regex highlighting breaks when emojis are present

Author: cyriltoblerCreated Sep 12, 2025Updated Sep 12, 2025

When using a regex pattern that highlights text containing emojis, the match highlighting appears incorrect. Instead of highlighting only the intended characters, the highlighting becomes misaligned due to emojis being counted incorrectly in the string.

Image

Expected Behavior: The regex should highlight the entire line after the first uppercase letter, regardless of emojis.

Actual Behavior: The highlighter forgets to highlight as many characters as there are emojis.

  • With 1 emoji → 1 character is not highlighted
  • With 2 emojis → 2 characters are not highlighted
  • With 3 emojis → 3 characters are not highlighted

Environment:

  • only in PCRE