stripColons static method

String stripColons(
  1. String name, [
  2. void errorCall(
    1. String message
    )?
])

Strip colons for emoji name. So, ':heart:' will become 'heart'.

Implementation

static String stripColons(String name, [void Function(String message)? errorCall]) {
  Iterable<Match> matches = EmojiParser.regexName.allMatches(name);
  if (matches.isEmpty) {
    if (errorCall != null) {
      errorCall(EmojiMessage.errorMalformedEmojiName);
    }
    return name;
  }
  return name.replaceAll(EmojiConst.charColon, EmojiConst.charEmpty);
}