bjorn.now

#background-work

The extra work to understand how things work because you just want to know, not strictly necessary to get the thing done right now, but you walk away better at your craft, and better equipped for the future. Inspired by Kent Beck's Background Work post.

08 October, 2025

The regex | (or) operator splits the pattern left or right unless explicitly grouped. Group it using (pattern) if you need to use the match later, or as a non-capturing group (?:pattern) if you do it for clarity.

I used to think there was some magic rule about how | decided where to split, but it’s simply: characters and subpatterns concatenate into a single pattern first, then | splits the entire thing left and right unless you explicitly group it. That’s because | has the lowest precedence so all other operations happen first.

So while I used to think that prefix_cat|dog would match prefix_cat and prefix_dog, it actually matches prefix_cat and then dog.

And that exact problem in a real-world example, to find if a page is linking to another, both relative or full URL:

[… more]
til Updated 2 min read #how-to, #regex, #background-work

23 September, 2025

Recycling bins are for packaging, not the products themselves. Wooden ice cream stick? That’s “other,” it’s part of the product, at least in Karlstad. The wrapper? That goes in the appropriate recycling bin based on material.

This seems to be based on EU law, which makes sense, so I’ll assume the gist of this is true in other EU countries too.

[… more]
til 2 min read #background-work

15 August, 2025