class Unicode::DisplayWidth

def self.emoji_width_via_possible(string, emoji_set_regex, strict_eaw = false, ambiguous = DEFAULT_AMBIGUOUS)

Match possible Emoji first, then refine
def self.emoji_width_via_possible(string, emoji_set_regex, strict_eaw = false, ambiguous = DEFAULT_AMBIGUOUS)
  res = 0
  # For each string possibly an emoji
  no_emoji_string = string.gsub(REGEX_EMOJI_ALL_SEQUENCES_AND_VS16){ |emoji_candidate|
    # Check if we have a combined Emoji with width 2 (or EAW an Apple Terminal)
    if emoji_candidate == emoji_candidate[emoji_set_regex]
      if strict_eaw
        res += self.of(emoji_candidate[0], ambiguous, emoji: false)
      else
        res += 2
      end
      ""
    # We are dealing with a default text presentation emoji or a well-formed sequence not matching the above Emoji set
    else
      if !strict_eaw
        # Ensure all explicit VS16 sequences have width 2
        emoji_candidate.gsub!(REGEX_EMOJI_VS16){ res += 2; "" }
      end
      emoji_candidate
    end
  }
  [res, no_emoji_string]
end