I'm using a name validation in Javascript. I found this code on internet. It's working fine.
I'm not getting why do we need to use the asterisk(*) symbol here? Code is not working without this also.
var pattern=/^([A-Za-z ]*)$/g;
CodePudding user response:
It's to matches any length of that capture group (([A-Za-z ])
). I would recommend https://regexr.com/ if you run in to problems with regex as it includes a good explanation for all expressions