← Back to challenges

RegEx XIII: Hexadecimal Character Class

PythonHardregexformattingvalidation

Instructions

You might get text that looks like it's all English characters but it very well may not be: pànts != pants

To ensure that you only get the characters you want in a string you will need to use the character classes that accept hexadecimal digits.

Write a regular expression that will match the word "innokodakademija". Use the hexadecimal character classes \x or \u in your expression.

You are not allowed to use any of the following characters: \w, \W, \d, \D, \t, \T, \S, \c, ., [, ] as well as any of the letters in the word innokodakademija.

Example

txt = "innokodakademija"
pattern = "yourregularexpressionhere"

bool(re.match("^{}$".format(pattern), txt)) ➞ True

Notes

  • You don't need to write a function, just the pattern.

  • Do not remove import re from the code.

  • You might want to use a raw string for this challenge.

  • You can find all the challenges of this series in my Basic RegEx collection.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.