Webflags: g

HTML Entity

Match HTML entities in named (`&`), numeric (`{`), or hex (`💩`) form.

Try it in RegexPro →

Available in

Pattern

regexengine-agnostic
&(?:[a-zA-Z][a-zA-Z0-9]+|#\d+|#x[0-9a-fA-F]+);   (flags: g)

Raw source: &(?:[a-zA-Z][a-zA-Z0-9]+|#\d+|#x[0-9a-fA-F]+);

How it works

The leading `&` and trailing `;` bracket the entity. The middle alternation matches: a named entity ([a-zA-Z][a-zA-Z0-9]+ — letters then alphanumerics, like `amp`, `lt`, `nbsp`); a decimal entity (#\d+, like `#160`); or a hex entity (#x[0-9a-fA-F]+, like `#xA0` or `#x1F600` for emoji).

Examples

Input

Tom & Jerry <3

Matches

  • &
  • <

Input

Numeric:   Hex: 😀

Matches

  •  
  • 😀

Input

no entities here

No match

Common use cases

  • HTML scraping and entity decoding
  • Email template entity validation
  • Migrating legacy HTML to UTF-8
  • Sanitization pipelines that strip non-ASCII via entities