match everything until parenthesis

you would use ^[^\(]+ to match that and then trim it to remove the trailing space


To avoid the trailing whitespace, try ^.*?(?=\s\().

^(.*?) tells it to match as few characters as possible, from the start of the string, and the (?=\s\() anchors the other end of the match to your paren, without capturing it or the whitespace before it.


^[^\(]*

[^\(] is a character class, which matches everything except for (, and * is a greedy match, which matches the class as many times as possible. The ^ at the beginning matches from the beginning of the string.

Tags:

Regex

R