How can i detect string is start with "+"
I tried
^\s*?\+.*$
but no help.
P.s: I have only one line alltime.
^\+.*$
should work for your purposes.
Here's a fiddle with a couple test strings : https://regex101.com/r/nP2eL7/1
Without regex, you can also use native method startsWith()
.
So it would be:
var str1 = '+some text';
var bool = str1.startsWith('+'); //true
You don't need
\s*?
, you have to use:In case you want to check a complete string, you can use:
Working demo