4 points

Today, to configure fail2ban. Before that, yesterday to select which tests to run.

permalink
report
reply
1 point

Usually I use glob patterns for test selection.

But I did use reges yesterday to find something else. A java security file definition.

permalink
report
parent
reply
2 points

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.

permalink
report
reply
1 point
*

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

permalink
report
parent
reply
1 point

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)

permalink
report
parent
reply
8 points
*

At least once every few days while coding, usually to do one of the following:

  1. Select multiple things in the same file at the same time without needing to click all over the place

    Normally I use multicursor keyboard shortcuts to select what I want and for the trickier scenarios there are also commands to go through selections one at a time so you can skip certain matches to end up with only what you want.

    But sometimes there are too many false matches that you don’t want to select by hand and that’s where regex comes in handy.

    For instance, finding:

    • parent but not apparent, transparent, parentheses, apparently, transparently
    • test but not latest, fastest, testing, greatest, shortest
    • trie but not entries, retries, countries, retrieve
    • http but not https

    … which can be easily done by searching for a word that doesn’t include a letter immediately before or immediately after: e.g. \Wtest\W.

  2. Search for things across all files that come back with too many results that aren’t relevant

    Basically using the same things above.

  3. Finding something I already know makes a pattern. Like finding all years: \d{4}, finding all versions: \d+\.\d+\.\d+, finding random things that a linter may have missed such as two empty lines touching each other: \n\s*\n\s*\n, etc…

permalink
report
reply

Yesterday. Gotta grep those logs.

permalink
report
reply
2 points
*

Earlier this week for a character range.

/edit: Now I remember. For setting up a new entry in Jenkins CI build failure analysis - identifying the build failure cause in the log.

permalink
report
reply

Programming

!programming@programming.dev

Create post

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 !webdev@programming.dev



Community stats

  • 3.6K

    Monthly active users

  • 1.8K

    Posts

  • 29K

    Comments