How do I add code to remove leading and trailing spaces to this regular expression?
I tried putting the \s in several places, but end up with odd results.
The myString is just the way it is, and is sent from a PHP script with trailing spaces.
Original Code
var myString = "::This is string 1 ::This is string 2! ";
myString = myString.replace(/\::(.+?)(?![^::])/g,'<li>$1</li>');
alert(myString);
Tried
var myString = "::This is string 1 ::This is string 2! ";
myString = myString.replace(/\::(.+?)(?![^::\s])/g,'<li>$1</li>');
alert(myString);
The end result I'm trying to achieve is
<li>This is string 1</li> // No trailing spaces before or after the `This` and `1`
<li>This is String 2</li>
::(.+?)\s*(?=::|$)