Groovy syntax for regular expression matching

前端 未结 3 1089
终归单人心
终归单人心 2020-12-24 01:07

What is the Groovy equivalent of the following Perl code?

my $txt = \"abc : groovy : def\";
if ($txt =~ / : (.+?) : /) {
  my $match = $1;
  print \"MATCH=$m         


        
3条回答
  •  渐次进展
    2020-12-24 01:42

    This was the closest match to the Perl code that I could achieve:

    def txt = "abc : groovy : def"
    if ((m = txt =~ / : (.+?) : /)) {
      def match = m.group(1)
      println "MATCH=$match"
    }
    

提交回复
热议问题