I've slightly revised my example as I don't need to escape \ the asterisk as it is within a character class, and the global modifier is unnecessary with
test():
Code:
var expr = "**";
var regex = /[^*]/;
if (!expr.length || expr == '') {
alert('Empty string');
} else if (!regex.test(expr)) {
alert('Just stars.');
}
The regex.test() expression essentially says "return
true as soon as you find a character other than an asterisk, otherwise return
false".