Back to Browse

Writing A Grep Clone In 9 Lines Of Python - Python Regular Expressions Tutorial

3.2K views
Oct 29, 2020
8:43

In this video we show how you can use Python's regular expressions module to build a clone of the popular Unix tool 'grep' using only 9 lines of Python code. You can find the source code and a text version of this video here: https://blog.robertelder.org/grep-clone-in-9-lines-of-python/ Corrections: For the first example, I used the regex "[A-Z]N0" which will match any line that contains this pattern *anywhere* even part-way through a model number (so you'd only end up matching the last half of the model number). This could be fixed in Python by using a pattern like this instead: ", \s*[A-Z]N0". This way it will match the previous comma followed by any number of spaces before the model number, then followed by the model number pattern. SOCIALS ---------------- Patreon: https://www.patreon.com/RobertElderSoftware?utm_source=yt&utm_medium=desc&utm_campaign=ytchannel&utm_content=KcqpBZMz294 Tiktok: https://www.tiktok.com/@roberteldersoftware Linkedin: https://linkedin.com/company/robert-elder-software Blog: https://blog.robertelder.org/?utm_source=yt&utm_medium=desc&utm_campaign=ytchannel&utm_content=KcqpBZMz294 Twitter: https://twitter.com/RobertElderSoft Twitch: https://www.twitch.tv/roberteldersoftware Github: https://github.com/RobertElderSoftware Facebook: https://www.facebook.com/RobertElderSoftware Instagram: https://www.instagram.com/roberteldersoftware/ Merch: https://store.robertelder.org/?utm_source=yt&utm_medium=desc&utm_campaign=ytchannel&utm_content=KcqpBZMz294

Download

0 formats

No download links available.

Writing A Grep Clone In 9 Lines Of Python - Python Regular Expressions Tutorial | NatokHD