janlelis/unicode-emoji: Up-to-date Emoji Regex in Ruby - GitHub
文章推薦指數: 80 %
require "unicode/emoji" string = "String which contains all kinds of emoji: - Singleton Emoji: 😴 - Textual singleton Emoji with Emoji variation: ... Skiptocontent {{message}} janlelis / unicode-emoji Public Notifications Star 125 Fork 10 Up-to-dateEmojiRegexinRuby character.construction MITLicense 125 stars 10 forks Star Notifications Code Issues 1 Pullrequests 0 Actions Projects 0 Wiki Security Insights More Code Issues Pullrequests Actions Projects Wiki Security Insights main Branches Tags Couldnotloadbranches Nothingtoshow Loading {{refName}} default Couldnotloadtags Nothingtoshow {{refName}} default Loading 1 branch 23 tags Code Loading Latestcommit Gitstats 97 commits Files Permalink Failedtoloadlatestcommitinformation. Type Name Latestcommitmessage Committime .github/workflows data lib/unicode spec .gitignore CHANGELOG.md CODE_OF_CONDUCT.md Gemfile MIT-LICENSE.txt README.md Rakefile unicode-emoji.gemspec Viewcode Unicode::Emoji Gemfile Usage Regex MainRegexes PickingtheRightEmojiRegex SingletonRegexes IncludeTextualEmoji ExtendedPictographicRegex PartialRegexes List Properties AlsoSee MIT README.md Unicode::Emoji ProvidesUnicodeEmojidataandregexes,incorporatingthelatestUnicodeandEmojistandards. AlsoincludesacategorizedlistofrecommendedEmoji. Emojiversion:14.0(September2021) CLDRversion(usedforsub-regionflags):40(October2021) SupportedRubies:3.0,2.7 NolongersupportedRubies,butmightstillwork:2.6,2.5,2.4,2.3 IfyouarestuckonanolderRubyversion,checkoutthelatest0.9versionofthisgem. Gemfile gem"unicode-emoji" Usage Regex ThegemincludesabunchofEmojiregexes,whicharecompiledoutofvariousEmojiUnicodedatasources. require"unicode/emoji" string="Stringwhichcontainsallkindsofemoji: -SingletonEmoji:😴 -TextualsingletonEmojiwithEmojivariation:▶️ -Emojiwithskintonemodifier:🛌🏽 -Regionflag:🇵🇹 -Sub-Regionflag:🏴 -Keycapsequence:2️⃣ -SequenceusingZWJ(zerowidthjoiner):🤾🏽♀️ " string.scan(Unicode::Emoji::REGEX)#=>["😴","▶️","🛌🏽","🇵🇹","🏴","2️⃣","🤾🏽♀️"] MainRegexes Matches(non-textual)Emojiofallkinds: Regex Description ExampleMatches ExampleNon-Matches Unicode::Emoji::REGEX Usethisifunsure!Matches(non-textual)singletonEmoji(exceptforsingletoncomponents,likeaskintonemodifierwithoutbaseEmoji)andallkindofrecommendedEmojisequences 😴,▶️,🛌🏽,🇵🇹,2️⃣,🏴,🤾🏽♀️ 😴︎,▶,🏻,🇵🇵,🏴,🤠🤢 Unicode::Emoji::REGEX_VALID Matches(non-textual)singletonEmoji(exceptforsingletoncomponents,likeaskintonemodifierwithoutbaseEmoji)andallkindofvalidEmojisequences 😴,▶️,🛌🏽,🇵🇹,2️⃣,🏴,🏴,🤾🏽♀️,🤠🤢 😴︎,▶,🏻,🇵🇵 Unicode::Emoji::REGEX_WELL_FORMED Matches(non-textual)singletonEmoji(exceptforsingletoncomponents,likeaskintonemodifierwithoutbaseEmoji)andallkindofwell-formedEmojisequences 😴,▶️,🛌🏽,🇵🇹,2️⃣,🏴,🏴,🤾🏽♀️,🤠🤢,🇵🇵 😴︎,▶,🏻 PickingtheRightEmojiRegex UsuallyyoujustwantREGEX(RGIset) Ifyouwantbroadermatching(e.g.moresub-regions),chooseREGEX_VALID Ifyouevenwanttomatchforinvalidsequences,too,useREGEX_WELL_FORMED Pleaseseethestandardfordetails. Property REGEX(RGI/Recommended) REGEX_VALID(Valid) REGEX_WELL_FORMED(Well-formed) Region"🇵🇹" Yes Yes Yes Region"🇵🇵" No No Yes TagSequence"🏴" Yes Yes Yes TagSequence"🏴" No Yes Yes TagSequence"😴" No No Yes ZWJSequence"🤾🏽♀️" Yes Yes Yes ZWJSequence"🤠🤢" No Yes Yes Moreinfoaboutvalidvs.recommendedEmojiinthisblogarticleonEmojipedia. SingletonRegexes Matchesonlysimpleone-codepoint(+optionalvariationselector)Emoji: Regex Description ExampleMatches ExampleNon-Matches Unicode::Emoji::REGEX_BASIC Matches(non-textual)singletonEmoji(exceptforsingletoncomponents,likeaskintonemodifierwithoutbaseEmoji),butnosequencesatall 😴,▶️ 😴︎,▶,🏻,🛌🏽,🇵🇹,🇵🇵,2️⃣,🏴,🏴,🤾🏽♀️,🤠🤢 Unicode::Emoji::REGEX_TEXT MatchesonlytextualsingletonEmoji(exceptforsingletoncomponents,likedigit1) 😴︎,▶ 😴,▶️,🏻,🛌🏽,🇵🇹,🇵🇵,2️⃣,🏴,🏴,🤾🏽♀️,🤠🤢 IncludeTextualEmoji Bydefault,textualEmoji(emojicharacterswithtextvariationselectororthosethathaveadefaulttextpresentation)willnotbeincludedinthedefaultregexes.However,ifyouwishtomatchforthemtoo,youcanincludetheminyourregexbyappendingthe_INCLUDE_TEXTsuffix: Regex Description ExampleMatches ExampleNon-Matches Unicode::Emoji::REGEX_INCLUDE_TEXT REGEX+REGEX_TEXT 😴,▶️,🛌🏽,🇵🇹,2️⃣,🏴,🤾🏽♀️,😴︎,▶ 🏻,🇵🇵,🏴,🤠🤢 Unicode::Emoji::REGEX_VALID_INCLUDE_TEXT REGEX_VALID+REGEX_TEXT 😴,▶️,🛌🏽,🇵🇹,2️⃣,🏴,🏴,🤾🏽♀️,🤠🤢,😴︎,▶ 🏻,🇵🇵 Unicode::Emoji::REGEX_WELL_FORMED_INCLUDE_TEXT REGEX_WELL_FORMED+REGEX_TEXT 😴,▶️,🛌🏽,🇵🇹,2️⃣,🏴,🏴,🤾🏽♀️,🤠🤢,🇵🇵,😴︎,▶ 🏻 ExtendedPictographicRegex Unicode::Emoji::REGEX_PICTOmatchessinglecodepointswiththeExtended_Pictographicproperty.Forexample,itwillmatch✀BLACKSAFETYSCISSORS. Unicode::Emoji::REGEX_PICTO_NO_EMOJImatchessinglecodepointswiththeExtended_Pictographicproperty,butexcludesEmojicharacters. Seecharacter.construction/pictoforalistofallnon-Emojipictographiccharacters. PartialRegexes MatchespotentialEmojiparts(often,thisisnotwhatyouwant): Regex Description ExampleMatches ExampleNon-Matches Unicode::Emoji::REGEX_ANY MatchesanyEmoji-relatedcodepoint(butnovariationselectors,tags,orzero-widthjoiners).PleasenotthatthiswillmatchEmoji-partsratherthancompleteEmoji,forexample,singledigits! 😴,▶,🏻,🛌,🏽,🇵,🇹,2,🏴,🤾,♀,🤠,🤢 - List UseUnicode::Emoji::LISTorthelistmethodtogetagrouped(andordered)listofEmoji: Unicode::Emoji.list.keys #=>["Smileys&Emotion","People&Body","Component","Animals&Nature","Food&Drink","Travel&Places","Activities","Objects","Symbols","Flags"] Unicode::Emoji.list("Food&Drink").keys #=>["food-fruit","food-vegetable","food-prepared","food-asian","food-marine","food-sweet","drink","dishware"] Unicode::Emoji.list("Food&Drink","food-asian") =>["🍱","🍘","🍙","🍚","🍛","🍜","🍝","🍠","🍢","🍣","🍤","🍥","🥮","🍡","🥟","🥠","🥡"] PleasenotethatcategoriesmightchangewithfutureversionsoftheEmojistandard.Thisgemwillissuewarningswhenattemptingtoretrieveoldcategoriesusingthe#listmethod. AlistofallEmojicanbefoundatcharacter.construction. Properties AllowsyoutoaccessthecodepointdataformUnicode'semoji-data.txtfile: require"unicode/emoji" Unicode::Emoji.properties"☝"#=>["Emoji","Emoji_Modifier_Base"] AlsoSee Unicode®TechnicalStandard#51 Emojicategories RubygemwhichdisplaysEmojisequencenames Partofunicode-x MIT Copyright(C)2017-2021JanLelishttps://janlelis.com.ReleasedundertheMITlicense. Unicodedata:https://www.unicode.org/copyright.html#Exhibit1 About Up-to-dateEmojiRegexinRuby character.construction Topics ruby emoji unicode regex emoji-unicode sequence unicode-data Resources Readme License MITLicense Codeofconduct Codeofconduct Releases 23 tags Usedby112 +104 Contributors5 Languages Ruby 100.0% Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1janlelis/unicode-emoji: Up-to-date Emoji Regex in Ruby - GitHub
require "unicode/emoji" string = "String which contains all kinds of emoji: - Singleton Emoji: 😴 ...
- 2How to get all available emojis in an array in Swift - Apple ...
I want to be able to get an array of all the available emojis in Swift. ... ://stackoverflow.com/...
- 3Regex to match all emoji - Regex Tester/Debugger
Regular Expression to As seen here, this should match all official emoji as of Dec 2018. ... Regu...
- 4What is the regex to extract all the emojis from a string? - Stack ...
Using emoji-java i've wrote a simple method that removes all emojis including fitzpatrick modifie...
- 5Full Emoji List, v14.0 - Unicode