isPersian static method

bool isPersian(
  1. String input, {
  2. bool complex = false,
})

Validates if the input string contains only Persian characters @param input The string to validate @param complex Whether to use complex Persian character set @returns bool True if input is valid Persian text Example: PersianTools.isPersian("سلام") => true

Implementation

static bool isPersian(String input, {bool complex = false}) {
  if (input.isEmpty) return false;
  final RegExp pattern = RegExp('["\'-+()؟\\s.]');
  final String rawText = input.replaceAll(pattern, "");
  final String faRegExp = complex ? _faComplexText : _faText;
  return RegExp("^[$faRegExp]+\$").hasMatch(rawText);
}