replaceNumberWithKorean static method
Replaces numeric characters in the text with their Korean representations.
Parameters:
text
: The input text to be processed.
Returns the text with numeric characters replaced by their Korean representations.
Implementation
static String replaceNumberWithKorean(String text) {
String result = '';
String currentNumber = '';
bool isNumber = false;
for (int i = 0; i < text.length; i++) {
if (RegExp(r'[0-9]').hasMatch(text[i])) {
currentNumber += text[i];
isNumber = true;
} else {
if (isNumber) {
result += int.parse(currentNumber).numbersToKorean();
currentNumber = '';
isNumber = false;
}
result += text[i];
}
}
if (isNumber) {
result += int.parse(currentNumber).numbersToKorean();
}
return result;
}