如何打印部分线

bla*_*hli 0 regex printing groovy text

我在文本文件中搜索了包含该单词的所有行velcro.我现在想要打印这些行的内容,但只打印后面的部分velcro

说我有一行文字

the purple monkey climbs the velcro cactus

我将如何打印之后的所有内容velcro(寻找一般答案)

我开始时:

c = /.*velcro.*/

if (line ==~ c){
println ...
}
Run Code Online (Sandbox Code Playgroud)

ata*_*lor 5

在正则表达式中使用捕获组:

c = ~/.*velcro(.*)/

m = line =~ c
if (m) {
    println m[0][1]
}
Run Code Online (Sandbox Code Playgroud)