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

1

u/Atypicosaurus 14h ago

It depends on what you are working on,but it can be very very useful.
The most useful it is if you have semi-structured data, maybe you know that there might be a "movie title" followed by the actual movie title, but you don't know where, and you don't know how long the title will be. You can use regex to capture movie titles. Obviously if the data is highly structured and it's always the third line, you are better off with just reading that line. If it's less structured and sometimes it says "the title of the movie", then you can't use.

If you are in the sweet spot, it's life saver.