Character Class
Matching Specific Characters
You have a test string S. Your task is to write a regex that will match S with following conditions:
S must be of length:
6First character:
1,2or3Second character:
1,2or0Third character:
x,sor0Fourth character:
3,0,AoraFifth character:
x,soruSixth character:
.or,
^[1-3][120][xs0][30Aa][xsu][\.,]$Excluding Specific Characters
You have a test string S. Your task is to write a regex that will match S with the following conditions:
S must be of length
6.First character should not be a
digit(1, 2, 3, 4, 5, 6, 7, 8, 9 or 0).Second character should not be a
lowercase vowel(a, e, i, o or u).Third character should not be
b,c,DorF.Fourth character should not be a
whitespace character( \r, \n, \t, \f or <space> ).Fifth character should not be a
uppercase vowel(A, E, I, O or U).Sixth character should not be a
.or,symbol.
^[^\d][^aeiou][^bcDF][^\s][^AEIOU][^\.,]$Matching Character Ranges
Write a RegEx that will match a string satisfying the following conditions:
The string’s length is >= 5.
The first character must be a lowercase English alphabetic character.
The second character must be a positive digit. Note that we consider zero to be neither positive nor negative.
The third character must not be a lowercase English alphabetic character.
The fourth character must not be an uppercase English alphabetic character.
The fifth character must be an uppercase English alphabetic character.
^[a-z][1-9][^a-z][^A-Z][A-Z]Last updated
Was this helpful?