I have strings such as:
foo bar
foo bar
foo
foo
I want to write a regex to capture the inner text in a capture group and ignore any leading and trailing whitespace, i.e., match foo bar
and foo
respectively. Since I am doing this in Rust, I cannot use lookahead.
I tried ^\s*(.*)\s*$
. However, this includes the trailing whitespace in the capture group (since matching is greedy I guess).