Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下字符串:
def s="txtimgtxtvdd"
我想从上面的字符串中提取一个列表,如下所示
def l=["txt","img","txt","vdd"]
每 3 个连续的字母是一个列表项
您可以使用collate(并将toList字符串拆分为字符列表)
collate
toList
def part = 'txtimgtxtvdd'.toList().collate( 3 )*.join() assert part == ['txt', 'img', 'txt', 'vdd']