r/learnpython • u/ASIC_SP learnbyexample • Jan 11 '19
I wrote a book on Python Regular Expressions, it is FREE through this weekend
Hello!
I've just released my book on Python Regular Expressions and it is free to download till 13-Jan-2019. You can still pay if you wish :)
e-book link: https://leanpub.com/py_regex/c/P7erPYAm1386
you will continue to get free updates in future, you'll need to opt-in to get notification via e-mail
github repo: https://github.com/learnbyexample/py_regular_expressions
This book would help you learn regular expressions step by step with 200+ examples, from basics to advanced levels. In addition to re module that comes with standard library, the 3rd party regex module is covered as well. Exercises are also included to test your understanding.
Table of Contents
Preface
Why is it needed?
Regular Expression modules
Anchors
Alternation and Grouping
Escaping metacharacters
Dot metacharacter and Quantifiers
Working with matched portions
Character class
Groupings and backreferences
Lookarounds
Flags
Unicode
Miscellaneous
Gotchas
Further Reading
Hope you find the book useful. I would be grateful for your feedback and suggestions.
Happy learning :)
3
u/ManMadeStructure Jan 21 '19
Damn it I just got into python last week
2
u/ASIC_SP learnbyexample Jan 22 '19
regex is intermediate to advanced level topic, so you've got some time to get used to Python first ;)
I would likely add some more stuff to the book and do another giveaway here, so keep a lookout on this sub
also, there are plenty of other resources to learn from... here's a list from this book:
CommonRegex - collection of common regular expressions
stackoverflow: regex tag is a good source of exercise questions
rexegg - tutorials, tricks and more
regular-expressions - tutorials and tools
regexcrossword - tutorials and puzzles
regexper - for visualization
regex101 - visual aid and online testing tool for regular expressions, select flavor as Python before use
debuggex - railroad diagrams for regular expressions, select flavor as Python before use
swtch - stuff about regular expression implementation engines
2
2
u/Kalaumes Jan 11 '19
Thank you very much for this.
While Friedl was the first serious book, I read about regular expressions, and is still a good resource, even the 3rd edition is somewhat aged (2006) and -- more important -- Friedl has no language-specific material about Python.
So, your book closes a very serious gap.
I like it.
1
u/ASIC_SP learnbyexample Jan 12 '19
Thanks. Providing language specific material was one of my motivation to write this book. I learnt a lot in the process too.
2
u/2_lazy Jan 11 '19
Hi! I have one suggestion. It would be nice to have a "preview" of the first couple pages so buyers know whether it will be helpful to them or not.
1
u/ASIC_SP learnbyexample Jan 12 '19 edited Jan 16 '19
Thanks, that is a great suggestion, I will add it soon.
edit: preview chapters are now available
2
Jan 11 '19 edited Jan 11 '19
Awesome! I love regular expressions. I was thinking of learning sed and awk next, but this book might change my plans. What's the target audience? How much Python should I know before reading this book?
Plus: not to be a choosing beggar, since you did a great thing already, but why just PDF? Epub and Mobi formats can be very handy, and exporting is trivial for most markup languages.
1
u/ASIC_SP learnbyexample Jan 12 '19
For sed/awk and other cli based text processing, I have a github repo: https://github.com/learnbyexample/Command-line-text-processing (I plan to create books out of them too, if possible)
Target audience for this book would be anybody using Python and consistently coming across text processing problems like sanitizing input string, extracting portions of string, etc. Not intended for processing csv/json/xml/etc as they have their own specialized modules.
You'd need to know programming basics and be familiar with Python syntax, plus a few concepts like list comprehension. You can ask me if you are stuck somewhere.
Regarding formats, yeah I need to see how to create epub/mobi formats. I am not familiar with pandoc and when I tried creating epub, I was facing issues. So, I focused in first getting out the book. I have some more stuff planned to add to the book and next version will likely have those formats as well for download.
2
u/fernly Jan 11 '19
Hello, fellow Leanpub author here. Leanpub is home to quite a number of inexpensive Python books but yours doesn't show up in that search (yet?). Anyway I look forward to having a look and reporting any typos.
1
u/ASIC_SP learnbyexample Jan 16 '19
No idea why it doesn't show up
Which book(s) have you written?
1
u/fernly Jan 16 '19
You should ask about the search maybe on the Leanpub author forum. Your book still doesn't show despite having Python in the title.
This is my book on Leanpub.
1
u/ASIC_SP learnbyexample Jan 17 '19
will check out the author forum, thanks :)
your book cover is well done!
2
Jan 12 '19
You have a problem and you want to solve it using regular expressions? You now have two problems.
2
u/ASIC_SP learnbyexample Jan 16 '19
:D I have used that quote as part of very first exercise..
I have also linked to Jeff's brilliant article in the book on that quote: Regular Expressions: Now You Have Two Problems
2
u/Shwuupe Jan 12 '19
Thanks for the work. Was curious if you might have/know other books like this that could be useful?
1
u/ASIC_SP learnbyexample Jan 12 '19
depends on which topics you are interested in
here's a curated list of resources I made for Python - many of them are free resources, might help :)
2
u/Shwuupe Jan 12 '19
Wow. The response time on this is wonderful! Thank you so much Yeah, I'm jumping into Python again only recently. Been going into theoreticals with Practical Theory of Programming and Treehouse for other basic info. Once I get comfortable enough I'm going to design my own projects and hopefully have some decent things to throw onto my portfolio webpage (which is also still in the works)
1
2
u/edixon653 Jan 12 '19
this is highly appreciated! Started this morn and it is a highly informative and enjoyable read thus far :) Thank you!
1
u/ASIC_SP learnbyexample Jan 13 '19
wow, thanks a lot :)
those are words authors wish to hear from their readers, helps to keep us going and do better the next time :)
113
u/saulmessedupman Jan 11 '19 edited Jan 11 '19
I've got 99 problems and regular expressions are every one of them.
Edit: thanks for the silver anonymous!
7
u/toomanyteeth55 Jan 12 '19
I have a love-hate relationship with regular expressions
4
u/saulmessedupman Jan 12 '19
I really want to know how they work under the hood. Is it just a big ugly list of if/else that would be equally annoying to write out the long way?
3
Jan 12 '19
Usually it’s implemented as a Finite State Machine, from what I vaguely remember from delving into PCRE many years ago.
3
u/saulmessedupman Jan 12 '19
Now I'm even more confused. But tbh the last time I read about a finite state machine was college 15 years ago
2
28
u/riphawk81 Jan 11 '19
Thank you. Just starting to get in to Python and every little bit I learn helps. Always nice to have ready reference material like this.
3
15
9
16
7
Jan 11 '19
Thank you! Been a python dev for about 5 years now, and am always on the lookout for new material. Anyone who freely contributes to the community is a hero of mine! Thank you for all your hard work! Will add it to my reading list :D
6
6
5
5
5
5
4
4
4
u/omelettesforbreakfas Jan 11 '19
Wow perfect timing. Literally just made the commitment to myself to learn regular expressions this weekend. Thanks!
4
4
4
u/daretogo Jan 11 '19
Using simple regex available in NotePad++ find/replace functions have already been such a useful tool to me, and I've known for a while that it could be leveraged much more powerfully with Python - this is perfect timing for me - thank you!
4
4
1
u/Gabe_Isko Jan 12 '19
Hmm, site complained about me not inputting a valid email address when I did. While trying to get a book about regular expressions....
1
u/ASIC_SP learnbyexample Jan 12 '19
if you are still facing issues, please DM your e-mail and I'll send you a copy
2
u/Gabe_Isko Jan 12 '19
Oh jo, we are good. Just seemed like it was an error in address validation regex.
3
3
4
2
u/insomnux Jan 11 '19
Thank you for this, I definitively need something like this. Thanks for your work and for sharing!
2
u/Guymzee Jan 11 '19
A single line of re makes me shudder. Thanks further free share! Looking forward to working through it.
2
2
2
2
2
2
2
2
2
2
2
u/seveninstl Jan 11 '19
Regular expressions are hard in any language! This is sure to help, thanks :)
2
2
2
2
2
2
2
2
u/swehttamxam Jan 12 '19
Download button only works on desktop view...TYVM for sharing this cool book!!!!!
2
2
2
u/eDOTiQ Jan 12 '19
Thank you! I guess I should stop being lazy and finally learn how to use regex properly
2
u/EmersonEXE Jan 12 '19
RemindMe! 5 days
1
u/RemindMeBot Jan 12 '19
I will be messaging you on 2019-01-17 03:48:31 UTC to remind you of this link.
CLICK THIS LINK to send a PM to also be reminded and to reduce spam.
Parent commenter can delete this message to hide from others.
FAQs Custom Your Reminders Feedback Code Browser Extensions
2
2
u/BATORAAAAA Jan 12 '19
Started delving into Python again to make lil calculators for my games; this will be very helpful!
2
2
u/GBWI Jan 12 '19
Thanks for sharing such a great book. I have downloaded this book and will read it.
2
2
2
4
u/whalt Jan 12 '19
Just grabbed it for free but feeling a little guilty since it's obvious you put a lot of work into it. If I find it useful I'll definitely come back and buy it. Thanks for sharing!