Example:
a) asdf ghjk (qwer . - tzui
b) asdf ghjk (qwer . - tzui)
c) asdf ghjk (qwer . - tzui) opyx
What I want is to match (qwer . - tzui in a and (qwer . - tzui) in b and c. So if an ending bracket exists, it should only match until that, otherwise until the end.
I’m not really a regex expert so I could only come up with \(.*\) for the second and third case which is quite trivial.
Try this
See it here online on Regexr
The
?makes the previous expression optional, that means the closing bracket is now optional.[^)\n\r]replaces your.to have a non greedy matching and means match every character but)\n\r. I added\n\rto avoid matching accross rows, if that is now problem you can remove them and leave only[^)]