Trying to create a pattern that matches an opening bracket and gets everything between it and the next space it encounters.
I thought \[.*\s would achieve that, but it gets everything from the first opening bracket on. How can I tell it to break at the next space?
Trying to create a pattern that matches an opening bracket and gets everything between
Share
The
.*is a greedy, and will eat everything, including spaces, until the last whitespace character. If you replace it with\S*or[^\s]*, it will match only a chunk of zero or more characters other than whitespace.Masking the opening bracket might be needed. If you negate the \s with ^\s, the expression should eat everything except spaces, and then a space, which means up to the first space.