regex matching alpha character followed by 4 alphanumerics

EDIT: Grrr… edited regex due to new “clarification” 🙂 ^[A-C][a-zA-Z0-9]{4}$ EDIT: To explain the above Regex in English… ^ and $ mean “From start to finish” (this ensures that the whole string must perfectly match) [A-C] means “Match either A, B, or C“ [a-zA-Z0-9]{4} means “Match 4 lower case letters, upper case letters, or numbers”

Regex get domain name from email

[^@] means “match one symbol that is not an @ sign. That is not what you are looking for – use lookbehind (?<=@) for @ and your (?=\.) lookahead for \. to extract server name in the middle: (?<=@)[^.]+(?=\.) The middle portion [^.]+ means “one or more non-dot characters”. Demo.