Mostly unrelated, but I use the opposite trick to ensure that the "grep" process itself doesn't show up when I "ps | grep" for a process. Something like: ps -ef | grep "myprogra[m]" Is still a regex that matches the string "myprogram", but it doesn't match itself , so the "grep myprogram" doesn't show up in the output. Easier than doing " | grep -v grep" or similar.
Regex that only matches itself
51–60 of 66 posts
Re: Regex that only matches itself
#52Earlier quoted context omitted.
And monads.
My suspicion is that no one wants to explain monads because if they did it would be painfully obvious that they're a purgatorial way of getting around the basic mismatch between functional purity and actual computers.
Re: Regex that only matches itself
#53Earlier quoted context omitted.
In Haskell and PureScript, Monad is a typeclass just like any other. They are an abstraction, effectful computation is not inherent to them, they represent computational contexts, e.g. the list monad is used to model non-determinism, the maybe monad represents computations that can fail, both of these are pure. This is an excellent set of posts for building an intuition about monads: http://mvanier.livejournal.com/39…
> the list monad is used to model non-determinism See this is the kind of thing that made learning Haskell so hard for me. I'm not a math guy, I'm terrible at math. I have no idea what "non-determinism" means, and I'd venture to guess that list monad is used to model "ordered collections of things".
If you have a `Stream decks;` of card decks, and want to get all the cards from all the decks, you might try to do something like `decks.map(deck -> deck.getCards().stream())`, but that will give you the type `Stream>`. That sucks, we just want a single stream, not a stream of streams, so we call the function that flattens at the same time. `decks.flatMap(deck -> deck.getCards().stream())`.
Nondeterminism is just a standard use for this construction: given one choice, generate more choices, given that choice, generate more choices, do some computation with the choices, and then return the list of possible final results.
Re: Regex that only matches itself
#54Mostly unrelated, but I use the opposite trick to ensure that the "grep" process itself doesn't show up when I "ps | grep" for a process. Something like: ps -ef | grep "myprogra[m]" Is still a regex that matches the string "myprogram", but it doesn't match itself , so the "grep myprogram" doesn't show up in the output. Easier than doing " | grep -v grep" or similar.
I just use pgrep for this now.
Re: Regex that only matches itself
#55I wish I was as smart as these people.
These are smart people of course, but it's easy to get overly impressed by these results because all the scaffolding is missing. Behind such a result, there is a lot of tinkering, many leads going into dead ends. By the time you hit a solution, you have in your mind a theory of why it works and you can start cutting it down by removing anything non essential. You end up with a clean result that seems almost magical.
Then you see "\z|\1\Q^\z|\1\Q>", and you can't even begin to parse it. For one, I didn't know you could add a quantifier to a recursive pattern. Then there is a backreference to what appears to be an empty capture, which is part of an alternation for fuck's sake, which also happens to include the \Q notation.
I imagine I am in the top 20-30% of regular expression users. And I straight up do not understand a single aspect of how this expression manages to match anything, let alone its intended purpose.
It doesn't matter how this regex was found. Whether it was obtained through an entirely manual process or assisted by some kind of AI, it's beyond incredible. 99.9999xxx% of senior software developers who have been programming for 30+ years could not come up with this if they were given 10 years to try and discover it out without 3rd party assistance.
>> These are smart people of course, but it's easy to get overly impressed
How bloody arrogant, and frankly a bullshit statement from someone who has no idea what they are talking about. This is amazing. Someone would have to sit down with me for at least a week - probably 3+ months - to even begin to explain to me exactly how this works.
Why did I take this comment so personally? I don't know, it sounds like the parent has never even seen a regular expression, and yet is trying to promote their own sense of worth as if they're a genius when in fact they have an IQ of 40. That somehow the people who managed to figure this out are only lucky to have done so, rather than there being any significant time or skill involved. I bet you there are less than a thousand human beings on Earth who could have solved this. It's likely that the people who fucking designed and wrote PCRE could not have even solved this.
Basically, stfu. Why do you have to comment only to diminish someone else's success story? You couldn't have solved this, so don't even try to minimize the achievements of others.
Re: Regex that only matches itself
#56Re: Regex that only matches itself
#57Re: Regex that only matches itself
#58I wish I was as smart as these people.
Everybody is a Genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein
Re: Regex that only matches itself
#59Earlier quoted context omitted.
These are smart people of course, but it's easy to get overly impressed by these results because all the scaffolding is missing. Behind such a result, there is a lot of tinkering, many leads going into dead ends. By the time you hit a solution, you have in your mind a theory of why it works and you can start cutting it down by removing anything non essential. You end up with a clean result that seems almost magical.
If you know anything about regular expressions, perhaps considering yourself a fairly decent expert... you might even know how to write basic recursive regexes. Then you are like me and think you know how to begin ripping apart any regex. Then you see " \z|\1\Q^ \z|\1\Q>", and you can't even begin to parse it. For one, I didn't know you could add a quantifier to a recursive pattern. Then there is a backreference to w…
Re: Regex that only matches itself
#60Earlier quoted context omitted.
"non-determinism" implies unordered.
See, to me, the sequence of keypresses I make while banging on my keyboard seem like it could be represented as an ordered list. I may be missing something, though.
But the idea of a list also suggests an ordering to me.