處理給定字符串的每個正則表達式組(見下一節)匹配的子字符串。
用法
void eachMatch(String regex, Closure clos)
參數
- Regex - 要搜索的字符串表達式
- 關閉 - 可選的關閉
返回值
沒有返回值。
示例
以下是使用此方法的示例 -
class Example {
static void main(String[] args) {
String s = "HelloWorld";
s.eachMatch(".") {
ch -> println ch
}
}
}
當我們運行上述程序時,我們將得到以下結果 -
H e l l o W o r l d
相關用法
- Groovy exp()用法及代碼示例
- Groovy equals()用法及代碼示例
- Groovy endsWith()用法及代碼示例
- Groovy equalsIgnoreCase()用法及代碼示例
- Groovy matches()用法及代碼示例
- Groovy after()用法及代碼示例
- Groovy padRight()用法及代碼示例
- Groovy contains()用法及代碼示例
- Groovy before()用法及代碼示例
- Groovy pow()用法及代碼示例
- Groovy sin()用法及代碼示例
- Groovy concat()用法及代碼示例
- Groovy random()用法及代碼示例
- Groovy Maps get()用法及代碼示例
注:本文由純淨天空篩選整理自 Groovy - eachMatch()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。