← Back to challenges

RegEx IV: Positive Lookahead

PythonHardlanguage_fundamentalsregexstrings

Instructions

Write a regular expression that will match the states that voted yes to President Trump's impeachment. You must use RegEx positive lookahead.

Example

txt = "Texas = no, California = yes, Florida = yes, Michigan = no"
pattern = "yourregularexpressionhere"

re.findall(pattern, txt) ➞ ["California", "Florida"]

Notes

  • You don't need to write a function, just the pattern.
  • Do not remove import re from the code.
  • This is fake data and used only for educational purposes.
  • 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.