I am attempting to make a regex to recongise a complex script declaration such as:
script void bar(type foo, type baz)
Where both "type"'s are in the same capture group
currently, I have the Regex:
(script)\s(\w*)\s(\w*)\((?:([a-z|A-Z]+)\s\w+)?\)
This recognises capture groups, as shown in the link. https://regex101.com/r/nB3oL3/3
- [0-6]
script
- [7-11]
void
- [12-15]
bar
- [16-20]
type
It also recognises the strings
script void bar(type foo)
script void bar()
Which is exactly what I want, except for the fact that it will not recognise any additional parameters such as "type baz"
script void bar(type foo, type baz)
I'm struggling to work out a way of recursively recognising the "type" in
", type baz"addition without adding additional capture groups (if this is even possible?). I was also unsure if I needed to use a branch reset for this effect?
As i'm doing this for sublime, I figure it must be using the python regex engine.
Any help would be much appriciated!
- Chris