Last active
January 21, 2019 02:44
-
-
Save huantt/d664abf490de6b7614abe6bb1fbbff09 to your computer and use it in GitHub Desktop.
Regex get string between 2 words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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