Onor.io
Anyone who uses regex with Elixir (especially with Unicode) would be wise to read this essay by Dr. Jamie Jennings on the subject and why it can be such a minefield of problems:
Trending in Discussions
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
Hi there! :wave:
@frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
Lately I’ve been thinking about how to organize components as a LiveView application grows. One of the pain points I’ve found (for myself...
New
What IDE or editor are you using for Elixir development?
Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
Other Trending Topics
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
One more reason to like Rust’s
regexlibrary – because it doesn’t do lookbacks.Qqwy
Quite the interesting read!
I’m looking forward to part two which is hinted at actually going to talk about the Regex lookback operation.
As someone who has done some work on parsers, lexers and state-machines, I completely understand the frustration that arises from an over-use of “regular” expressions that attempt to add extra features to support a set of languages other than the set of regular languages, with subtle carnage as a result.
If other people like reading about this topic, I can also recommend this blog post about RipGrep which goes in detail on how it works, how it can be more efficient than other text-search tools out there, and why many of the other text-search tools go wrong in their search-implementations when Unicode is used.
kip
Very interesting read and given the work I’ve been doing in unicode and localisation is resonates strongly. In fact its part of why I got interested in this topic at all. There are tools and techniques in Unicode and CLDR that can help. Not the same as regex, or general string matching, but at least they have some formal underpinnings. Here’s an template example of how I approach this using some of the libs I maintain.
Looking forward to the next couple of parts of the article series.
bgrommes
In my experience, regex ends to be over-used, even when it’s the right tool to be using.
What I mean by this is that it’s often the most costly option in terms of performance, and complex regex expressions can be very tricky to get right and to troubleshoot.
I had a code base with some pretty straightforward Regex in it on hot paths that worked correctly but when we had to tune for performance, one of our biggest wins was to reduce the actual calls for regex with some sort of “gatekeeper” test. For example, if your regex is " STORE (#)?\d+$" and most of the strings you’ll examine won’t match, it’s FAR faster, even if your regex engine allows you to precompile, to do something like this:
Once you are clear that regex is an embedded just-in-time compiled DSL, these sorts of patterns write themselves. I get the impression that many devs think regex comes for free in terms of performance. I was aware that couldn’t be true, but even so I was surprised just how costly it actually is.
Also keep in mind that, regardless of topic, if what you’re implementing carries a lot of cognitive burdens and “gotchas” then it may not be the best answer. Regex is rife with these. Nontrivial regex is hard to read, easy to screw up, and has occult behaviors that are easy to forget you are triggering.
All that said, when you need regex, you REALLY need it. It’s like any number of things that can easily get away from you if you’re not careful – inheritance in OOP, for example. All things in moderation. They’re in the toolbox for a reason, not to go off on a bender and use for the wrong things.
On the topic of Unicode, well, I had the luxury in my most recent long-running assignment to be working effectively with 7-bit ASCII and so could simply ignore the issue. Mixed case slows you down and accents and ligatures greatly expand the problem space. All the more reason to keep regex simple and straightforward to the maximum possible extent.
Onor.io
Dr. Jennings has put up the second part of her blog post:
This one is on the idea of look-behind in a regex and the inherent issues in that technology. Again, another excellent read from someone who’s done a lot of research (and thinking) on RegEx’s!