So basically, I have a text like this:
secret(mapOf("path" to "config/info"))
secret(mapOf("path" to "config/data/${rootProject.name}"))
prefix(mapOf("path" to "config/${rootProject.name}", "format" to "${rootProject.name.replace('-', '_')}"))
I want to match a path like config/info
and not to match paths which contain variables (have dollar signs in them). I came up with this ((?:'|\")config/.+(?:'|\"))
but it also matches the others.
How can I exclude strings with dollar signs?
What you are looking for (if I fully understand your question) is this one:
(['\"]config/[^$]+['\"])
Explanation:
['"]
instead of (?:'|\")
I believe it will make your regex
readable and simple to understand in the future.[^$]+
instead of .+
is the key to solve your issue, .+
will match anything however [^$]+
will match anything as long as it's not $
.