source/Emoji/gemoji-parser/lib/gemoji-parser.rb
def unicode_matcher(patterns)
    # Strip off all trailing U_FE0F characters:
    patterns.map! { |p| p.gsub(U_FE0F_SUFFIX, '') }.uniq!

    # Return a single pattern directly:
    return patterns.first if patterns.length == 1

    # Sort patterns, longest to shortest:
    patterns.sort! { |a, b| b.length - a.length }

    # Use the longest pattern with U_FE0F optionalized, if possible:
    if patterns.all? { |p| p.gsub(U_FE0F, '') == patterns.last }
      patterns.first.gsub(U_FE0F, U_FE0F+'?')
    else
      patterns.join('|')
    end
  end
# Compiles an optimized unicode pattern for fast matching.
Compiles an optimized unicode pattern for fast matching.
Compiles an optimized unicode pattern for fast matching .
def unicode_matcher(patterns)
    patterns.map! { |p| p.gsub(U_FE0F_SUFFIX, '') }.uniq!
    return patterns.first if patterns.length == 1
    patterns.sort! { |a, b| b.length - a.length }
    if patterns.all? { |p| p.gsub(U_FE0F, '') == patterns.last }
      patterns.first.gsub(U_FE0F, U_FE0F+'?')
    else
      patterns.join('|')
    end
  end
def unicode_matcher ( patterns ) patterns . map! { | p | p . gsub ( U_FE0F_SUFFIX , '' ) } . uniq! return patterns . first if patterns . length == 1 patterns . sort! { | a , b | b . length - a . length } if patterns . all? { | p | p . gsub ( U_FE0F , '' ) == patterns . last } patterns . first . gsub ( U_FE0F , U_FE0F + '?' ) else patterns . join ( '|' ) end end
Compiles an optimized unicode pattern for fast matching.
Compiles an optimized unicode pattern for fast matching .
# Strip off all trailing U_FE0F characters: # Return a single pattern directly: # Sort patterns, longest to shortest: # Use the longest pattern with U_FE0F optionalized, if possible:
patterns