c# - Regex capturing group terminating early -
i don't ask dumb regex questions. here's 1 regex vultures....
take these strings...
-this nice (show cow) *this (or that) (show mouse) -whatever -hiya (everyone)
all these should match. ie lead *
or -
, text, can conditionally followed whitespace , (show xxx)
xxx
can text. want these captured separately ie...
-this nice (show cow) match 1 : 'this nice' match 2 : '(show cow)' or 'cow' *this (or that) (show mouse) match 1 : 'this (or that)' match 2 : 'show mouse' or 'mouse' -whatever match 1 : 'whatever' -hiya (everyone) match 1 : 'hiya (everyone)' +hello no match
i have tried variously...
[\-*](.+?)(\s+\(show (.+)\))? terminates , captures 1 char of match 1 [\-*](.+)(\s+\(show (.+)\))? terminates late , captures of text match 1 including `(show....` [\-*](.+)(\s+\(show (.+)\)$)? above
i'm sure should easy! don't want go negating (show
within match 1 - permit eg -hello (show a) (show b)
match 1 hello (show a)
, match 2 (show b)
(or b
)
Comments
Post a Comment