字串 replaceAll() 方法



用給定的值替換所有與指定模式相匹配的子字串。

語法

String replaceAll(Pattern from, String replace)

引數

  • From - 要替換的字串。

  • Replace - 替換字串。

返回型別

返回一個字串。

示例

void main() { 
   String str1 = "Hello World"; 
   print("New String: ${str1.replaceAll('World','ALL')}"); 
} 

將生成以下輸出 -。

New String: Hello ALL 
dart_programming_string.htm
廣告
© . All rights reserved.