I am trying to create a regExpr te define if a string contains a % or a whitespace or a combination of the 2.
Example:
'%%%%' ---> true
'% %%%' ---> true
'test%' ---> false
can someone help?
thx a lot
I am trying to create a regExpr te define if a string contains a % or a whitespace or a combination of the 2.
Example:
'%%%%' ---> true
'% %%%' ---> true
'test%' ---> false
can someone help?
thx a lot
You can use this regex,
^[% ]+$
Check this JS code demo,
var arr = ['%%%%','% %%%','test%']
for(s of arr) {
console.log(s + ' ---> ' +/^[% ]+$/.test(s));
}