Skip to content

Commit

Permalink
feat: Added a method for identifying pictograms.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed May 7, 2024
1 parent ca2e0d1 commit 7ce7a60
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/katana/lib/extension/string_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ extension StringExtensions on String {
/// メールアドレスの場合`true`を返します。
bool isEmail() {
return RegExp(
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9_-]+\.[a-zA-Z_-]+")
.hasMatch(this);
}

Expand All @@ -761,4 +761,18 @@ extension StringExtensions on String {
bool isURL() {
return RegExp(r'https?://[a-zA-Z0-9\-%_/=&?.]+').hasMatch(this);
}

/// Returns whether or not this string contains pictograms.
///
/// Returns `true` if the string contains pictograms.
///
/// この文字列に絵文字が含まれているかどうかを返します。
///
/// 絵文字が含まれている場合`true`を返します。
bool isEmoji() {
RegExp regExp = RegExp(
r"[\u{1F600}-\u{1F64F}|\u{1F300}-\u{1F5FF}|\u{1F680}-\u{1F6FF}|\u{2600}-\u{26FF}|\u{2700}-\u{27BF}]",
unicode: true);
return regExp.hasMatch(this);
}
}

0 comments on commit 7ce7a60

Please sign in to comment.