Valid Username Regular Expression

  • + 0 comments

    Well, I don't see a '.' (period) character in sinithwar's regex, but it normally is a "wildcard", which can match any one single character. For example, the pattern "ca." would match words like can, cap, car, cat, and so forth. However when inside a character class, it acts like a literal period. The '-' (hyphen) character is the other way around, being literal and boring on its own, but has a special meaning inside character classes. It lets you specify a bunch of characters very quickly. So, "[0-9a-f]" is the same as "[0123456789abcdef]". You could read it aloud as "everything from 0 to 9, inclusive, and also from a to f, inclusive". Hope that summary makes enough sense!