i have this string grafana-stack_alloy and require everything after the first underscore
alloy.
I need the result as a group $1. Tried this one, but it failed. (?:)?([^_]+)*$.
Can anyone help me to solve this problem?
I am testing this:
rule {
action = "replace"
source_labels = [
"__meta_docker_container_label_com_docker_swarm_service_name",
]
regex = "^(?:;*)?([^;]+).*$" work but wrong
//regex = "[^_]+.$" ----> not work
//regex = "([^_]+)$" ----> not work
replacement = argument.namespace.value + "/$1"
target_label = "job"
}
It is about the Grafana Agent with relabel-regex: Grafana prometheus.relabel which use Google's RE2 as its regex engine.
Thanks in advance
(?:)looks weird. Isn't(?:foo)a non-capturing version of(foo)in Perl regexes? But that would make(?:)a zero-length match... What's the intent here?