« first day (3676 days earlier)      last day (1271 days later) » 

12:00 AM
@AndrasDeak I was hoping to standardize on PCRE, which seems the most capable of the widely used regex dialects.
The more local flavors are often lacking.
Tom pointed me to a Python regex library called "regex", which is backwards compatible to re. I even had it installed (the Python 2 version).
That's python-regex and python3-regex in Debian.
For example, Lua's built-in regex handling is kind of miserable, though better than nothing. Fortunately Lua does have a PCRE library available.
 
Yeah, regex is the one third-party library I know. But I don't know it well. The one difference I'm aware of is \K which is absent in re.
 
@AndrasDeak Is it more capable?
 
I've no idea. But I never felt that stdlib re is not capable enough. If something needs a powerful regex engine I don't use a regex for it. I value my sanity.
 
@AndrasDeak Hmm. What do you use then?
 
Just python, I guess. Though this is largely hypothetical. I rarely have to work with strings :)
 
12:12 AM
@AndrasDeak Ok. Well, my needs are often hypothetical too. I just like to have the biggest hammer available handy, in case I have to hit something really hard.
 
in my experience regex is one of the top contenders for "when you have a hammer everything starts to look like a nail (including your fingers)"
If something is hard to do with regex I never try to use regex. Odds are the problem is not even regular.
 
12:37 AM
@AndrasDeak There is probably some truth to that.
@AndrasDeak "the problem is not even regular"?
 
Yes. Regular languages are what can be easily described by regular expressions. When you try to parse irregular things with regex Bad Things start to happen
 
@AndrasDeak I see. Happily, I'm not insane enough to try to paste HTML with regex.
 
That's when you use PCRE!
 
An article on the GNU project. In the New Yorker. For some reason.
@MichaelHomer You do?
 
 
13 hours later…
1:21 PM
@Wildcard thanks again for the Krita tip, I just tried it. Works like a charm! At first I thought my stylus was misconfigured, because the button wouldn't draw, it would only move the canvas. Turns out that it was working better than I expected: I had to press the stylus on the tablet and it's just that the default tool's pressure profile was such that I had to press harder than expected.
I've switched to a flat pressure-profile tool and it seems perfect for my use case. Of course I'll spend an hour or two just figuring out where all the functionality is, but it does seem absolutely great
But I should sdd that gimp worked too :)
s/sdd/add/
 
2:36 PM
The only weird thing is that my debian settings don't seem to recognize the tablet and stylus. But as long as it Just Works I don't care.
 
 
2 hours later…
5:02 PM
@AndrasDeak Recognize in what sense?
 
@AndrasDeak That's just some front-end thingy.
You probably want to use some suitable tool.
 
That front-end thingy usually sets my stuff just fine. One exception is pavucontrol but I have non-trivial audio needs.
 
5:22 PM
@AndrasDeak Hurray for front-end thingys.
 
 
2 hours later…
7:21 PM
@AndrasDeak BTW, what front-end thingy was that, anyway?
 
The settings in gnome.
 
@AndrasDeak Oh. KDE user here. And I generally use low level utilities, anyway. So I know what's going on.
 
The gnome settings are quite alright. There's also gnome-tweaks (née gnome-tweak-tools) which adds some nice functionality, but I can almost always make do with the normal settings.
The two exceptions I can think of are printers (hp-setup usually works better) and the aforementioned audio
 
 
2 hours later…
9:04 PM
This is probably a dumb question and I should know the answer. And perhaps I do know and have forgotten. But why doesn't ( )+ work as an alternative to ` +` for a regex corresponding to at least one blank space?
 
because the regex flavour you're using needs \(\) for capture groups
>>> import re
... re.findall('( )+', 'potato  potatoe tomato')
[' ', ' ']
but the group will only capture the one space
>>> re.findall('([a-z])+ ([a-z]+)', 'aaa bbb')
[('a', 'bbb')]
At least in python. Haven't seen perl in 15 years ;)
 
9:19 PM
@AndrasDeak What does the regex used here mean?
 
It means "one or more spaces, but only capture the one"
so it does match multiple spaces, but when you use \1 later it will only contain one space
Hmm, this seems to be implementation dependent
$ grep -E '( )+' <<<'potato   potatoe'
potato   potatoe
$ sed 's/\( \)+/\1/' <<<'potato   potatoe'
potato   potatoe
in any case both match multiple spaces (but sed seems to capture all of them)
Ugh that's inconclusive, sorry
Will fix it soon
 
@AndrasDeak I tried ( )+ inside a regex, but it didn't work for me. But ` +` worked as expected. Python 3.7 on Debian stable/buster, though I doubt they'd change something like this across Python versions.
I could provide an example if you want.
 
9:35 PM
@FaheemMitha did you use re.match by any chance?
an example would probably help, yes
 
@AndrasDeak sub, actually. But the re module. I guess I forgot to mention that detail. :-)
 
>>> re.sub('( )+', 'POTAT', 'potato   potatoe')
'potatoPOTATpotatoe'
but again, only one is captured:
>>> re.sub('( )+', r'\1', 'potato   potatoe')
'potato potatoe'
so we should look at your example
 
The file as is, works correctly/as expected. But try the commented version of data_pattern.
That gives an error.
 
@FaheemMitha you probably forgot to account for the change in capture group numbering if you have 2 more capture groups
I left a comment with code including that adjustment, and it works
The error I got without the adjustment was a KeyError because ' ' is not a key in your dict. So the match was fine, but you were referring to the wrong group.
 
9:58 PM
@AndrasDeak So ( )+ corresponds to a capture group? I thought ( +) would.
I also didn't realise one could comment on a gist.
I also just received it as an email.
Perhaps ( )+ is just the first space, and ( +), though that seems a bit wacky.
 
@FaheemMitha exactly
for what it's worth I would also understand if ( )+ and ( +) did the same thing
@FaheemMitha you can disable that in your settings if it bothers you
and if my comment bothers you, I can delete it ;)
 
@AndrasDeak No, it's fine.
@AndrasDeak That should be documented somewhere. But the trouble with all these regex variations is that it leaves one not knowing exactly what's going to happen in a given situation with a given engine.
 
@FaheemMitha it probably is. Python has a well-documented standard library.
Not sure about re, because that started out as a third-party library a long time ago. I'll take a look.
 
@AndrasDeak I was looking through the re documentation. It's not exactly super detailed.
Of course, one could always look at the source code.
 
@FaheemMitha that is usually a pain with python
most of the stdlib is written in C...
 
10:14 PM
It might not be easy to understand. Especially if it is written in C.
 
found it
> If a group matches multiple times, only the last match is accessible:
And having thought about it a bit, it sort of makes sense. (a)+ should not correspond to (aaa). It should correspond to (a)(a)(a) at best. So the question is whether each should be a group of its own, perhaps.
 
10:55 PM
Moderators (cc @terdon who's technically in the room): I answered a question that somehow went HNQ, but the question is not amazing and afterward I realized that it's pretty much a dupe. Don't you think it should at least be kicked out of HNQ?
There's actually very little information about the circumstances and what works and how for OP.
 
11:39 PM
The only difference between regex libraries in that example is whether the captured group is the first or last match, which differs arbitrarily
 
Does my sed example not suggest that \( \)+ captures all three spaces?
2 hours ago, by Andras Deak
$ grep -E '( )+' <<<'potato   potatoe'
potato   potatoe
$ sed 's/\( \)+/\1/' <<<'potato   potatoe'
potato   potatoe
this one ^
Otherwise the match (three spaces) would be replaced by a single space (the capture group)
 
@AndrasDeak mods can remove Q's from HNQ; closed Q's should be removed automatically after 3 minutes, to my understanding based on meta.stackexchange.com/q/325060/307535 and others.
 
It suggests more that the string ` +` does not appear in the input (you have to escape the + too)
 
I won't judge the duplicate status on my own; and I'm not seeing lots of harm from it being Hot... are you?
 
sed -e 's/\(x\)+/\1/' <<<xxx => xxx but sed -e 's/\(x\)\+/\1/' <<<xxx => x
 
11:53 PM
@JeffSchaller I know they can, hence my question :)
@JeffSchaller no harm per se, it's just that I'm always annoyed when I see a question in HNQ and it turns out to be something lukewarm :)
like the one on physics right now that's due to gross confusion in the asker
 
Having said all that, there are three other U&L Q's on the HNQ list; I don't see that one right now.
 
Hmmm, me neither! I didn't know HNQ could expire so fast. Got hot 21 hours ago unix.stackexchange.com/posts/617362/timeline
or someone has already kicked it out :D
 
HNQ are selected slight better than they were before, but the computers aren't yet as good as humans would be at selecting them
 
@MichaelHomer derp
thanks
 
@AndrasDeak I don't see a timeline entry for it being kicked out (though I'm not 100% it would), but I do see an option for me to remove it from HNQ, suggesting it's still eligible.
Maybe you should cast a close-as-duplicate vote?
 
11:58 PM
Weird... Thanks. I don't think I've seen a timeline of a post that was kicked out so no idea if it would show up.
 
I haven't had the opportunity, so I'm ignorant in the subject
 

« first day (3676 days earlier)      last day (1271 days later) »