Hello Programmers, In this post, you will know how to solve the HackerRank Excluding Specific Characters Solution. This problem is a part of the Regex HackerRank Series.

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.
HackerRank Excluding Specific Characters Solution
[^]
The negated character class [^]
matches any character that is not in the square brackets.

Task
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
,D
orF
. - 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.
Note
This is a regex only challenge. You are not required to write any code.
You have to fill the regex pattern in the blank (_________
).
HackerRank Excluding Specific Characters Solutions in Cpp
HackerRank Excluding Specific Characters Solutions in Java
public class Solution { public static void main(String[] args) { Regex_Test tester = new Regex_Test(); tester.checker("^\\D[^aeiou][^bcDF][^\\r\\n\\t\\f\\s ][^AEIOU][^.,]$"); // Use \\ instead of using \ } }
HackerRank Excluding Specific Characters Solutions in Python
Regex_Pattern = r'^\D[^aeiou][^bcDF]\S[^AEIOU][^\.,](?=$)' # Do not delete 'r'.
HackerRank Excluding Specific Characters Solutions in JavaScript
var Regex_Pattern = /^\D[^aeiou][^bcDF]\S[^AEIOU][^\.,]$/;
HackerRank Excluding Specific Characters Solutions in PHP
$Regex_Pattern = "/^[^1,9][^aeiou][^bcDF][^\r\n\t\f\s][^AEIOU][^.,]$/"; //Do not delete '/'. Replace __________ with your regex.
Disclaimer: This problem (Excluding Specific Characters) is generated by HackerRank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.
Next: HackerRank Matching Character Ranges Solution