Every day pretty much with Unix tools. Vim, awk, sed, etc.
Usually many times a day… Even today which have been mostly meetings.
Yesterday. Gotta grep those logs.
Today.
Yesterday, for capturing URLs.
https?//[a-zA-Z0-9_-]*
I am kinda learning RE right now 😅
What about ftp? 🤔
If we want to include every protocol then the RE could be complex.
Depending on the use-case it maybe should. On the other hand, some things are better left to library implementations rather than custom regex, e.g. email validation
Yesterday, when I had a file with a list of JSON objects, and I wanted to move the date field at the end to the beginning, so I used regex find and replace to move it. Something like
\{(.*?), ("date": ".*?")
in Search, and then{$2, $1
in replace (or something close to it).Yes, I refactor code and data using regex. I can’t be arsed to learn AWK (even though I should).
AWK doesn’t work with json IIRC. You have to use jq to deal with json.
While yes, the way I had it structured looked like a CSV if you squinted a little, I do fully agree AWK can’t be used for just any old JSON.
jq
is dope, but that language still feels pretty confusing IMO.
I don’t always use regular expressions, but when I do, I use it to parse XML,
iirc using RE to parse tag languages is not recommended.
Sure, but if you are not regularly expressing code that has the potential of summoning elder gods that will swallow your soul into a dimension of ceaseless screaming then are you really living?
A few hours ago.
I just wanted to make a list of AD group names into a powershell array.
This sentence is the uncanny valley for structure.
Interesting to see a lot of these responses (so far) are workflow related instead of being used in production.
Probably, because in production there are really few things that are best done with regex. Most use I had for regex in production is filling in data from user-provided files with specifically crafted names, and even there there was some guesswork because of errors in naming, and the same thing may have been achieved without regex by splitting and/or iterating
Yesterday doing a search using vim for a class that shared a lot of characters at the front with many other classes: /Bas.*Some I could have done a more precise search with better regex, but this was quick, easy, and worked.
On average I’ve probably had to work with them or write one from scratch only a handful of times per year over my career. Not often enough to be an expert or anything but I’m not so afraid of them as I used to be.
Actually writing code that uses them: last month. Commandline: last week.
Asking this question is like asking when was the last time you had to search through text.
Today, to configure fail2ban. Before that, yesterday to select which tests to run.
Usually I use glob patterns for test selection.
But I did use reges yesterday to find something else. A java security file definition.