405
Views
10
Comments
Regex for emoji
Question

Good Day!, I have trouble handling emojis in Regex for input fields because I want my input field not to accept emojis but some are still accepted, here's the regex I used https://www.regextester.com/106421 

2019-09-24 18-41-25
Jorge Martins
 
MVP

Hi Philip,

Why don't you write your Regex to reflect what you accept, instead of what you don't? Emojis keep growing, seems like every new release of the Unicode standard comes with at least a few new ones.

2022-07-12 09-55-09
Philip Paolo De Castro

Jorge Martins wrote:

Hi Philip,

Why don't you write your Regex to reflect what you accept, instead of what you don't? Emojis keep growing, seems like every new release of the Unicode standard comes with at least a few new ones.


I already tried specifying the only character to be accepted on the regex (eg. Alphanumeric characters) however in an unknown reason, some emojis like the heart emoji still passes through. Have you experienced this kind of issue? This is for a mobile app. Thank you.


You can check the sample .oml file attached

RegexForEmoji.oml
2019-11-01 16-10-49
Nélio Dionisio

Hi,

In this link from the stack overflow they seem to have the solution, the regex that they found is: 

^[^\u{203C}\u{2049}\u{20E3}\u{2122}\u{2139}\u{2194}-\u{2199}\u{21A9}-\u{21AA}\u{231A}-\u{231B}\u{23E9}-\u{23EC}\u{23F0}\u{23F3}\u{24C2}\u{25AA}-\u{25AB}\u{25B6}\u{25C0}\u{25FB}-\u{25FE}\u{2600}-\u{2601}\u{260E}\u{2611}\u{2614}-\u{2615}\u{261D}\u{263A}\u{2648}-\u{2653}\u{2660}\u{2663}\u{2665}-\u{2666}\u{2668}\u{267B}\u{267F}\u{2693}\u{26A0}-\u{26A1}\u{26AA}-\u{26AB}\u{26BD}-\u{26BE}\u{26C4}-\u{26C5}\u{26CE}\u{26D4}\u{26EA}\u{26F2}-\u{26F3}\u{26F5}\u{26FA}\u{26FD}\u{2702}\u{2705}\u{2708}-\u{270C}\u{270F}\u{2712}\u{2714}\u{2716}\u{2728}\u{2733}-\u{2734}\u{2744}\u{2747}\u{274C}\u{274E}\u{2753}-\u{2755}\u{2757}\u{2764}\u{2795}-\u{2797}\u{27A1}\u{27B0}\u{2934}-\u{2935}\u{2B05}-\u{2B07}\u{2B1B}-\u{2B1C}\u{2B50}\u{2B55}\u{3030}\u{303D}\u{3297}\u{3299}\u{1F004}\u{1F0CF}\u{1F170}-\u{1F171}\u{1F17E}-\u{1F17F}\u{1F18E}\u{1F191}-\u{1F19A}\u{1F1E7}-\u{1F1EC}\u{1F1EE}-\u{1F1F0}\u{1F1F3}\u{1F1F5}\u{1F1F7}-\u{1F1FA}\u{1F201}-\u{1F202}\u{1F21A}\u{1F22F}\u{1F232}-\u{1F23A}\u{1F250}-\u{1F251}\u{1F300}-\u{1F320}\u{1F330}-\u{1F335}\u{1F337}-\u{1F37C}\u{1F380}-\u{1F393}\u{1F3A0}-\u{1F3C4}\u{1F3C6}-\u{1F3CA}\u{1F3E0}-\u{1F3F0}\u{1F400}-\u{1F43E}\u{1F440}\u{1F442}-\u{1F4F7}\u{1F4F9}-\u{1F4FC}\u{1F500}-\u{1F507}\u{1F509}-\u{1F53D}\u{1F550}-\u{1F567}\u{1F5FB}-\u{1F640}\u{1F645}-\u{1F64F}\u{1F680}-\u{1F68A}]*$

Hope it helps :)

2018-10-04 11-30-51
glenn michiels

Hi Philip,


The following regex matches all non-ascii characters including spaces until reaching an ascii character.

[^\x00-\x7F]+\ *(?:[^\x00-\x7F]| )*

Hope it helps.

Kind regards,

Glenn

2022-07-12 09-55-09
Philip Paolo De Castro

Thank you for the help guys, however some of the emojis are still being accepted. Maybe this is some of the limitations of OutSystems? 

2018-10-04 11-30-51
glenn michiels

Philip Paolo De Castro wrote:

Thank you for the help guys, however some of the emojis are still being accepted. Maybe this is some of the limitations of OutSystems? 

Philip,

Could you tell me which emoji's are still being accepted?
I'm working on a forge component ( RegexLib ) and an emoji filter seems like a useful regex to add.

Kind regards,

Glenn



2022-07-12 09-55-09
Philip Paolo De Castro

glenn michiels wrote:

Philip Paolo De Castro wrote:

Thank you for the help guys, however some of the emojis are still being accepted. Maybe this is some of the limitations of OutSystems? 

Philip,

Could you tell me which emoji's are still being accepted?
I'm working on a forge component ( RegexLib ) and an emoji filter seems like a useful regex to add.

Kind regards,

Glenn


Good day Glenn,

Here are some of the emoji's accepted using the regex you provided please see the attached image thank you hope it helps.



Emojis.JPEG
2019-09-24 18-41-25
Jorge Martins
 
MVP

Hi Philip,

this doesn’t seem to be an OutSystems limitation per se, the Regex functionality is supported directly by .NET framework functionality.

I believe it’s a matter of refining your regex further, but that’s not something I do too often, so can’t help you much further. I’d say you can get help for this in all the other forums not specific to OutSystems though, like stackoverflow, etc...

2022-07-12 09-55-09
Philip Paolo De Castro

Jorge Martins wrote:

Hi Philip,

this doesn’t seem to be an OutSystems limitation per se, the Regex functionality is supported directly by .NET framework functionality.

I believe it’s a matter of refining your regex further, but that’s not something I do too often, so can’t help you much further. I’d say you can get help for this in all the other forums not specific to OutSystems though, like stackoverflow, etc...


Oooh I see, Thank you!

2024-05-03 14-03-28
Sudip Dey

you can use the regex_search action from text API.

Please check the Link,

https://www.outsystems.com/forums/discussion/34651/using-regex-search/

I hope this will help you to update the code.

Please check and let me know your feedback.

Thank you,

Sudip

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.