I have a string like this:
' hello world '
I would like to match groups ' ', 'hello world', and ' '
I can't figure out how to allow spaces in the middle of the regex, where they aren't anchored to end
My attempt (http://regex101.com) /(^\s*)(.+)(\s*$)/g
' '? 2. Why do you need this in a single regex?^(\s*)(.*?)(\s*)$will work, but it might slow your code down significantly.trim()function? developer.mozilla.org/de/docs/Web/JavaScript/Reference/…