Go (RE2)

Emoji (Unicode) in GO

Match emoji characters across the main Unicode emoji ranges — requires the Unicode flag in JavaScript.

Try it in the GO tester →

Pattern

regexGO
[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{FE00}-\u{FEFF}\u{1F000}-\u{1F02F}\u{1FA00}-\u{1FA9F}]   (flags: gu)

Go (RE2) code

goGo
package main

import (
	"fmt"
	"regexp"
)

func main() {
	re := regexp.MustCompile(`[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{FE00}-\u{FEFF}\u{1F000}-\u{1F02F}\u{1FA00}-\u{1FA9F}]`)
	input := `Hello 🌍 World 🎉`
	for _, match := range re.FindAllString(input, -1) {
		fmt.Println(match)
	}
}

Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.

How the pattern works

The character class covers the primary emoji Unicode blocks: Miscellaneous Symbols and Pictographs (1F300–1F9FF), Misc Symbols (2600–26FF), Dingbats (2700–27BF), Variation Selectors (FE00–FEFF), Mahjong/playing cards (1F000–1F02F), and Supplemental Symbols (1FA00–1FA9F). The u flag in JavaScript is required to interpret \u{XXXXX} code points above 0xFFFF. In Python, use re.UNICODE (default in Python 3). In Go RE2, use \x{XXXXX} syntax instead of \u{XXXXX}.

Examples

Input

Hello 🌍 World 🎉

Matches

  • 🌍
  • 🎉

Input

⚡ Fast ☁ Cloud ⭐ Star

Matches

Input

plain text only

No match

Same pattern, other engines

← Back to Emoji (Unicode) overview (all engines)