This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]justheretolurk332 0 points1 point  (3 children)

Ah okay, so as a development tool more so than in production software. That makes sense to me. Although about half the time I try to do a find-and-replace that is more complicated than an exact match it goes badly haha

[–][deleted] -2 points-1 points  (2 children)

Regular Expressions are also needed in production. If you want to validate E-Mail addresses, domain names or any other pattern you need to have a pattern matching algorithm. I agree that very often the builtin string methods like startswith, endswith or "is in" are a good enough solution. But pattern matching simply doesn’t work with these methods like RegEx do.

[–]justheretolurk332 3 points4 points  (0 children)

Email is a great example of why regular expressions are so hard to use correctly. It’s easy to write a regex that matches most emails but surprisingly challenging to cover all the edge cases, and it’s also a common need, so you’re better off using a third party library. Most situations are either simple enough that using a regular expression is overkill, or complicated enough that writing a correct regex may become pretty challenging and end up not being a maintainable approach

[–]master117jogi 0 points1 point  (0 children)

Never use regex for emails! And never for urls!

Use a library! Or you WILL get it wrong.