I have a below peace of code :
Pattern p = Pattern.compile("^\\d|^\\W|^\\s");
Matcher m = p.matcher("stack overflow");
Can somebody explain the above regex pattern ? What it does ? I have to make it not allow spaces in between with the existing functionality .e.g. it should not allow "stack overflow " since it contains spaces .
EDIT
Below pattern I tried is working fine for me . Thanks all for your suggestion:
[a-zA-Z0-9_$#]