I want a regular expression which only allows a-z characters and 1 dot only between characters, not in the beginning or end of the string, here is what I’ve got:
var myRegexp = /^[a-zA-Z]*(\.{1}[a-zA-Z]*)?$/;
But it also allows the dot to be the first or the last character, how could I disallow dot in beginning or at the end of string?
The above code works in JS, how about the same regular expression in PHP with preg_match()?
Thanks in advance
The
*means 0-many. If you use a+then this will force at least 1 character to appear before and after the dot. i.e.