4 ms·
I'm confused by this: [^ab] means “everything but a or b ... . — The dot (.) matches any character, but not always. Sometimes it doesn’t match newl
by pcthrowaway 3y ago
I'm confused by this:
[^ab] means “everything but a or b
...
. — The dot (.) matches any character, but not always. Sometimes it doesn’t match newlines. In some programming languages it never matches newlines. I’ve gotten bitten too often by the . not behaving like I think it should. It’s best to ignore this entirely
Is the negation class somehow more standardized than the `.`? I mean, if you do [^X] it's typically going to match any character that isn't X except character returns and line feeds. `.` works the same way, except it will also match X. And for what it's worth, I can't think of the last time I ran into it somewhere that it also matched newlines
- mmh0000 3y agoCheck out this StackExchange thread which provides many answers[1] The TL;DR is, RegEx behaves slightly differently in each programming language. For example, if and how newlines are matched. There are three main flavors of RegEx: POSIX, Extended, and PCRE. Most UNIX tools implement either POSIX or Extended. Most Programming languages implement PCRE. Some programs (/cough vim/) just make up their own regex langauge as they go. [1] https://stackoverflow.com/questions/159118/how-do-i-match-any-character-across-multiple-lines-in-a-regular-expression https://stackoverflow.com/questions/159118/how-do-i-match-an...
- pcthrowaway 3y agoRight, I understand different regex flavors work differently; what I was questioning was whether the capture group negation syntax was any more "predictable" (for OP's concerns) than the `.` matching. Because the article recommends using a capture group negation to match a character when you know a specific character or set of characters won't be in the group, but doesn't mention why capture groups (and negations) are acceptable to use, while the `.` should be avoided ("because it might have this less predictable behaviour that I'm totally going to avoid talking about with capture group negations")
- satysin 3y agoHi mmh0000 apologies for replying like this but not long ago we had a little conversation regarding TRT. I replied to your last message but it is from a while ago and as HN doesn't alert you if you get a reply I've no idea if you read back through your older replies to see it. I was wondering if you had a bit of time to talk with me in private about TRT? I would be extremely grateful if you can and if so just drop me an email, my username satsyin at gmail will get to me. Thanks :)
- mmh0000 3y agoYes, please email me: mmh-hn-trt@xn0.org