stripColons static method

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

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

Implementation

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