Help with regex


(ext) #1

hi guys, pls help

a have text:

content := `
text0{%text,5-8%}text1{%text,5%}text2
`

and regex

pattern := regexp.MustCompile(`(?m)\{%(?P<key>\w+).(?P<value>\w+)%\}`)

how I can find {%text,5%} and {%text,5-8%} with one regex?
in my example I can find only {%text,5%}


(catacombs) #2

Maybe text, (5 | 5-8). This looks for both variations.


(ext) #3

I will try this thakyou


(catacombs) #4

You’re welcome. If that doesn’t work, try [5|5-8]. I can’t remember if it’s parentheses or brackets (and I’m on mobile).