I'm getting here after reading some other questions and examples like:
Groovy syntax for regular expression matching
Also this documentation I found online: https://e.printstacktrace.blog/groovy-regular-expressions-the-definitive-guide/
I was playing with it and I have what I think is a very basic regex but by some reason I always get no match.
So imagining I have a git url something like this: "ssh://git@bitbucket.sits.net/project/repo.git"
I want to extract in my groovy pipeline the project and repo itself: "ssh://git@bitbucket.sits.net/([a-zA-Z-]*)/([a-zA-Z-]*).git" (maybe there are smarter ways of doing this match but still should work)
Anyway the problem is that I'm testing this and at the moment I can't even make the simple ssh match, last alone my groups.
It works fine in an online regex tester

But it does not work in the groovy playground online.
This is the example (I'm testing it here https://groovy-playground.appspot.com/):
This input:
GIT_URL='ssh://git@bitbucket.sits.net/project/repo.git'
def match = GIT_URL =~ /ssh:\/\/git@bitbucket\.sits\.net\/([a-zA-Z-_]*)\/([a-zA-Z-_]*)\.git/
println match
Outputs no match:
java.util.regex.Matcher[pattern=ssh://git@bitbucket\.sits\.net/([a-zA-Z-_]*)/([a-zA-Z-_]*)\.git region=0,45 lastmatch=]
I've tried a few things but not even ssh match works
GIT_URL='ssh://git@bitbucket.sits.net/project/repo.git'
def match = GIT_URL =~ /ssh/
println match
java.util.regex.Matcher[pattern=ssh region=0,45 lastmatch=]
I thought it could be a problem in the tool but in my Jenkins pipeline it also does not work.
Also the example from the other question:
def match2 = "f1234" =~ /[a-z]\d{4}/
println match2
java.util.regex.Matcher[pattern=[a-z]\d{4} region=0,5 lastmatch=]