php – What is the regular expression for the graphic smiley?

Question:

I write a regular expression that matches the given string:

🆔 @id12345 (Сергей Иванов) 

Can't think of how to designate any graphic smiley? That is, instead of 🆔, any other can stand: ✔, ▶ and others. The regular expression will be used in the php script.

Answer:

Try using the So category.

From Unicode Character Properties:

General category

Symbols
Sm (symbol, math) – This category is for signs that are only used in mathematics. For example, in the expression "sin (π) = 0" only the equal sign can be categorized as Sm.
Sc (symbol, currency) – currency signs: cent (¢), dollar ($), lira (₤), euro (€), yen (¥), etc.
Sk (symbol, modifier) ​​- symbols for modifying sound and tone. These include the signs of sedilla, macron, dières, etc.
So (symbol, other) is an all-encompassing category of symbols that are not mathematical symbols, currency symbols, etc.

Regularity for example

/\p{So}/u 

Example https://regex101.com/r/CJJbHw/1

Scroll to Top