Regex to match a string that does not start and / or end with spaces, but allows trailing spaces
I need the regex to not match lines that start and / or end with space (s) but match between spaces. I am not a regex expert.
I can use 2 regular expressions if needed.
Note. Use .
to show space in examples.
matches false for
.text.
..text
text..
..te.xt..
matches true for
text
te..xt
I came up with this. It only matches the initial spaces.
^(?!\s+).*$
+3
source to share