I have seen a regular expression @"^[A-Z]+[a-zA-Z''-'\s]*$"
for checking whether a string is person's name and had the same question described in Regular Expression format meaning of [RegularExpression(@“^[A-Z]+[a-zA-Z''-'\s]*$”)] [duplicate]. Namely, what's the intention of [''-']
?
Since all [''-']
, [']
and ['-']
match single apostrophe, [']
should be enough and ['-']
looks redundant. However, I have seen this expression in several articles in MSDN and in books and so it seems a common pattern. I think there should be a legitimate reason to include ['-']
. The comments to above question doesn't go into this point.
Added
Just for reference, I add the articles in Microsoft that use this expression. ''
before hyphen is two consecutive single quotes but not double quotes.