← Back to challenges

RegEx X-A: Word Character Class

PythonHardregexstrings

Instructions

Write the regular expression that matches all alphabetic characters in a string. Use the character class \w in your expression.

Example

txt = "**^&$Regular#$%Expressions$%$$%^**"
pattern = "yourregularexpressionhere"

" ".join(re.findall(pattern, txt)) ➞ "Regular Expressions"

Notes

  • You don't need to write a function, just the pattern.
  • Do not remove import re from the code.
  • 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.
Next: A Simple Timer