I’m new to regular expressions, but I’d like to match a string up to when the numbers start.
So just say I have:
EEEE1234
Then I would like to extract only:
EEEE
I tried searching, but I find regular expressions confusing and the best way I think is through examples. Any thoughts? Also, any insight into any regex code generators or good tutorials on this?
Use \D to mean “not a digit”:
Example:
See it working online: ideone
You’ve already got some recommendations for tutorials, but I’d like to also add that if you haven’t yet seen the documentation for the
remodule, you should bookmark that and read that after you’ve read a more basic tutorial. The documentation is not beginner level but it has some very useful tips that are specific to using regular expressions in Python, and there also some examples near the end.