Groovy web console

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

extractInfoFromPackageJson

Published 2 weeks ago by Naval Gupta with tags extractVersion package.json nodeJs application version
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
String version='"version": "01.48.0",'
def matcher = version =~ '(?<="version": ")(\\d*)\\.(\\d*)\\.(\\d*)(?=")'
println "Project version: " + matcher[0]

String name = '"name": "apptest",'
matcher = name =~ '(?<="name": ").*(?=")'
println "Project name: " + matcher[0]