Created
December 8, 2025 18:24
-
-
Save kastoestoramadus/d02d1c9f9abec47e35640bef7fb1af2b to your computer and use it in GitHub Desktop.
include regexp
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
| import java.util.regex.*; | |
| String hocon = """ | |
| include "a.conf" | |
| include file("b.conf") | |
| include required("c.conf") | |
| include required file("bad.conf") | |
| include required "also.bad.conf" | |
| """; | |
| Pattern p = Pattern.compile( | |
| "(?m)^\\s*include\\s+(?:required\\(([^)]*)\\)|(?:file|url|classpath|resource)?\\(?\"?([^\"\\s)]+)\"?\\)?)" | |
| ); | |
| Matcher m = p.matcher(hocon); | |
| while (m.find()) { | |
| String inner = m.group(1) != null ? m.group(1) : m.group(2); | |
| System.out.println("FOUND: " + inner); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment