Fairly new to regex, looking to identify a user id pattern that is all alpha, is exactly 6 characters, and the second character is always a Z. Any help would be appreciated.
Asked
Active
Viewed 72 times
-4
-
Give us an example what you expect from a text as output – Makusium Jun 11 '20 at 14:47
-
[a-zA-Z]{1}\Z[a-zA-Z]{4} maybe – Alberto Sinigaglia Jun 11 '20 at 14:48
2 Answers
0
How about this regex:
\w(Z|z)\w{4}
Is this what you want?

Chris Ruehlemann
- 20,321
- 4
- 12
- 34
-
that doesn't find a match, an example would be bzh7wv. *Edit* It can include digits 1-9. – Josh Dixon Jun 11 '20 at 15:02
-
But you said the second char was always a "Z" (upper case!) Have edited the answer – Chris Ruehlemann Jun 11 '20 at 15:18
0
As I understood you want something to detect something like this:
jZabcd
What you could do is something like this:
[A-Za-z][Z]([A-Za-z]{4})
Breakdown:
[A-Za-z] = detects all alpha big and small letters only once.
[Z] = checks if there is only a big "Z".
() = a group to make it easier.
{4} = checks if there is 4 times from what was infront of the 4.
[A-Za-z]{4} = checks if there are 4 letters from big A-Z and small a-z.
I hope this helps you out and please expand your question next time a little more.

Makusium
- 201
- 1
- 2
- 15
-
Check out this https://stackoverflow.com/questions/4923380/difference-between-regex-a-z-and-a-za-z for what `A-z` actually matches! – Chris Ruehlemann Jun 11 '20 at 17:37
-
@ChrisRuehlemann thank you kind sir! Damn now I need to change all my codes from earlier projects...better now than later. – Makusium Jun 11 '20 at 20:31
-