Skip to content

Instantly share code, notes, and snippets.

@chumpa
Created August 21, 2018 05:21
Show Gist options
  • Select an option

  • Save chumpa/7d4869d55a7a1db88f58c208d7cb11a4 to your computer and use it in GitHub Desktop.

Select an option

Save chumpa/7d4869d55a7a1db88f58c208d7cb11a4 to your computer and use it in GitHub Desktop.
groovy regex
String x = "SFOData.FormHeader"
String y = "FormHeader"
List a(String w) {
String namespace="", local=""
(w=~/((?<namespace>\S*)\.)?(?<local>\S+)/).each {
(namespace,local)=it[2..3]
}
namespace ?= ""
[namespace, local]
}
def (namespace,local) = a(x)
println "$x: Namespace $namespace, local $local"
(namespace,local) = a(y)
println "$y: Namespace $namespace, local $local"
null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment