Groovy web console

subscribe to the feed Subscribe
to this
site
RPM spec regex (via #groovywebconsole)
tweet this snippet Tweet
this
script

RPM spec regex

Published 4 months ago by Robban with tags rpm regex
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def rpmspec = """
%define debug_package %{nil}

Name:   prometheus2
Version: 2.3.0
Release: 1%{?dist}
Summary: The Prometheus 2.3.0 monitoring system and time series database.
License: ASL 2.0
URL:     https://prometheus.io
Conflicts: prometheus

Source0: https://github.com/prometheus/prometheus/releases/download/v%{version}/prometheus-%{version}.linux-amd64.tar.gz
Source1: prometheus.service
Source2: prometheus.default

%{?systemd_requires}
Requires(pre): shadow-utils

"""

try{def finder = (rpmspec =~ /(?m)(^Source0:)/)
println finder.matches()
println finder.group(2)
} catch(error) {
    println "No match found in ${rpmspec}"
}