Skip to content

Instantly share code, notes, and snippets.

@huantt
Last active January 21, 2019 02:44
Show Gist options
  • Select an option

  • Save huantt/d664abf490de6b7614abe6bb1fbbff09 to your computer and use it in GitHub Desktop.

Select an option

Save huantt/d664abf490de6b7614abe6bb1fbbff09 to your computer and use it in GitHub Desktop.
Regex get string between 2 words
String regex = "(?<=GET ).*(?=\\ HTTP)";
Pattern pattern = Pattern.compile(regex);
new File("src/main/resources/access.log.2019-01-18.log").readLines().each { line ->
def matcher = pattern.matcher(line)
if (matcher.find()){
matcher.group(0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment