24
submitted 1 week ago by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 2 points 1 week ago

We use it for triaging test failure (running tens of thousands of tests for CPU design verification).

That use is acceptable because it is purely informational. In general you should avoid regexes at all costs. They're difficult to read, and easy to get wrong. Generally they are a very big red flag.

Unfortunately they tend to get used where they shouldn't due to lazy developers not parsing things properly.

[-] [email protected] 1 points 1 week ago* (last edited 1 week ago)

regexes are a well established solution for parsing strings. what exactly is the "proper" alternative you propose?

[-] [email protected] 1 points 1 week ago

There are some tools/libraries that act as a front-layer over regex.

They basically follow the same logic as ORMs for databases:

  1. Get rid of the bottom layer to make some hidden footguns harder to trigger
  2. Make the used layer closer to the way the surrounding language is used.

But there's no common standard, and it's always language specific.

Personally I think using linters is the best option since it will highlight the footguns and recommend simpler regexes. (e.g. Swapping [0-9] for \d)

this post was submitted on 04 Jul 2024
24 points (92.9% liked)

Programming

16304 readers
349 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS