Groovy Quiz 29 | Regular Expressions


Reference video | Groovy Playground


1 Point for every correct answer | Let’s Get Started

1.

A regular expression, regex or regexp is a sequence of characters that define a search pattern.

Patterns used to find substrings in a text

 

 
 

2.

Guess the output

You can run and check the code here – https://groovy-playground.appspot.com/

def match = "Groovy" =~ "Groovy"
println match[0]
 
 
 
 

3.

Guess the output

You can run and check the code here – https://groovy-playground.appspot.com/

def match = "Groovy" =~ "123"
if(match){
    println match[0]
}else{
    println "No match found"
}
 
 
 
 

4.

Guess the output

You can run and check the code here – https://groovy-playground.appspot.com/

def match = "Groovy" =~ "o"
if(match){
    def num=0
    while(match){
    print match[num]
    num++
    }
}else{
    println "No match found"
}
 
 
 

6