Example strings:
This is "a" test
This & test
This test string-has more words
In each of the above examples I have strings of words of varying lengths. Each of these strings is followed by a series of spaces and nothing after that.
My application uses ()
around sections of the regex to return only that portion of the matched pattern if necessary.
I need a regex that will return the full string regardless of length, minus the spaces on the end.
My current is (.*)\s{1,}$|(.*\S)$
This works if there are 0 spaces at the end of the string or 1 space at the end of the string, but 2 spaces or more, and the spaces are included in the output.