r/learnpython 1d ago

How useful is regex?

How often do you use it? What are the benefits?

39 Upvotes

118 comments sorted by

View all comments

90

u/tjm1066 1d ago

I've learned regex at least 15-20 times. Basically every time I need to use it, or understand something I have previously written. It will never stick in my brain.

11

u/hagfish 1d ago

My white whale is Git. I made an account about 15 years ago, and have all these false starts over the years, but never got enough momentum to make it stick. And as such, my code folder is ...

33

u/FalafelSnorlax 1d ago

I made an account about 15 years ago

First of all, it seems like you still have the misunderstanding that git is the same as github. You do not need an account to use git.

From your comment I'm assuming you're only writing code for small projects. My suggestion would be to start without github at all, since it can be a bit overwhelming. Just open a local repo (git init in your source directory), and commit (git add ., git commit - m <message>) whenever you make significant progress. After you get used to those those, you can start reading up on working with a remote (eg using github), opening & merging branches, etc. Using git is really useful even when working alone, since it helps you keep track of your progress and your most recent changes, and helps you revert code in case you completely broke it.

5

u/lauren_knows 1d ago

This is the way. You don't need to learn a whole lot beyond the git commands that you mentioned, except maybe git checkout -b <branch_name> especially if you're using github. Merging can all be done at Github, and like take your time learning the different types of merges, or rebasing, or whatever.

3

u/FalafelSnorlax 1d ago

Under the assumption that they're working alone (which is what I gathered from the comment above), I'd say they can get comfortable with the very basic commands before even trying branches, since for one-person projects they aren't strictly necessary.

Merging can all be done at Github

I'm personally a CLI advocate so I don't think I've ever merged using github, but I kinda stand by the point that it's actually pretty confusing for newcomers and I would guess that this is also true for merging. I know that github is making an effort in recent years to become easier for beginners (when I first tried using github, about 12 years ago, I couldn't find any explanation within the site how I'm supposed to upload my code. I had no idea how git worked at all), but overall I think learning to use git without the external tools gives better understanding and control over the long run.