如果我有一个像这样的字符串:
s = "This is a simple string 234 something else here as well 4334
和正则表达式如:
regex = ~"[0-9]{3}"
如何使用该正则表达式从字符串中提取所有单词?在这种情况下234和433?
您可以使用CharSequence.findAll:
def triads = s.findAll("[0-9]{3}") assert triads == ['234','433']