I have a university assignment to write a JS regex for name validation: name can include spaces at the beginning and the end (don't ask anything, it's our teacher demand), also it can include such chars like: -, ' and space (" "). At the moment, my regex looks like that:
var Nameregex = /^( ?)*[A-Z]+((['-])?[a-z]+)*(([ ]?[a-z]*)*)*$/g;
It works almost perfect, but except for one case: one word (words separated from each other with spaces and - symbols) can contain only one ' symbol.
For example, names like John-andrew'andrew'john shouldn't work. But John-andrew'john-andrew'john should work.