« first day (287 days earlier)      last day (1150 days later) » 
03:00 - 16:0016:00 - 20:00

3:27 AM
🤔
 
 
6 hours later…
9:49 AM
o/ @Scratte
 
10:05 AM
Hello :)
 
Ok so where should I get started from 😅
I remember that you had a doubt
Mar 1 at 23:28, by Scratte
Why does this match?: ^..(?<=(?=1).)
 
@Yatin That's an Indian wording only :)
@Yatin Yes, that one may have an explanation. But only guesses so far.
 
Hun? You guys don't say that?
 
@Yatin No. English or western people never say "I have a doubt". They say "I have a question"
 
Oh
 
 
1 hour later…
11:16 AM
Do you have any guesses to what is going on with that?
 
I thought about it for some time but I don't know tbh...
 
11:35 AM
Have you learnt about back-references?
Like: (.)\1
 
🤔
What does that have to do with this?
 
11:56 AM
Everything :)
 
:O
Details/clarity required.
 
12:12 PM
How about self-referencing groups, like (^.|\1)+$? :)
 
Hm
Is the ? part of the regex 😅
@Scratte This is soo strange
 
No.. the ? is not part of the regex.. sorry :)
 
@Scratte Nah I was just pulling your leg 😉 I knew it wasn't
 
Well.. I could see how one could get confused about it.
Anyway.. tell me what it matches and how it works :)
 
@Scratte I... I don't even know where to start thinking about it...
Can you give me some example text to test on?
 
12:20 PM
Ok :) Closed: Needs more focus :D
 
Hehe
 
No.. I'll ask a few questions instead: What is group(0)? And what is group(1)?
 
Hm... zero will be the entire thing and 1 will be ^.|\1
 
Right. When the regex starts, is there anything in group(1)?
 
Hm... there should be... the first charecter...
 
12:22 PM
It just started.. :) It's looking at the first character.
 
No. Nothing then
 
Right, so it can't possibly match anything that is nothing. Nothing is not the same as empty. Empty is () and nothing is null :)
 
So. Group 1 will be empty?
 
Oops. No group(1) is null, not empty. Can it match ^. ?
 
No
 
12:25 PM
Why not? It's at the beginning of the string? :)
Try going to regex101 and put ^. in the regex and a few lines in the "Text String" :)
Yes. Is the first character at the beginning of a line? :)
 
But why will group 1 be empty then?
 
@Yatin When it's matched the first character, then the groups is exited and then the first character will be in group(1). But before the first character is matched, there's nothing in the group, so the self-reference cannot be matched.
That means: Either match the first character of a string OR match what is in group(1), no? :)
 
So wait, when my cursor is at the start of the line, I am matching the first character no? Then shouldn't it be in group 1?
@Scratte Yes but... (match | ignore this) -- the entire thing is in a group so it will be in group 1...
 
Not before you have matched it. Only when it has reached the end-parenthesis is the match for group(1) stored.
first time it gets to the group, it will be like this:
at this point nothing is stored --> (
--> ^.|\1 <-- here matches are attempted.
) <-- here whatever was matched is stored into the group.
 
@Scratte :O
@Scratte Yes
 
12:36 PM
:)
Basically this is what happens with (^.|\1)+$:
At the first character group(1) is null and cannot be matched, so the only other option is ^. (it actually will always try the first thing first, but that's not what this is about :-)
 
🤔🤔
Also, ^. will run only once right?
 
after it has matched the first character the group is exited and that character is stored into group(1). Now the + is reached and it goes back into the group.
@Yatin Only once on every line, obviously :)
 
So
Say I have aaaaa
First it matches a
Then it tries to match a and finds it
Then it tries aa and finds it
 
Yes :) No..
 
Yes or no ? 😂
 
12:41 PM
@Yatin Yes
@Yatin No
 
Ok wait
Hm... It looks for a only doesn't it?
Because a was in group 1?
 
Correct. How could that ever change to aa? :)
 
Nah my bad...
if it were \0
 
Ahh.. but a group is not set until it's exited.. so group(0) is practically empty until a full match has been made :)
 
:o
 
12:45 PM
You could argue that the process is first an a, then an a.. and in the end group(0) will contain all the a's. But that is just a way of building the variable in your own head :)
It's like String s = "a" + "a" + "a"; <-- At no point does s only contain one or two a's :)
 
Makes sense :)
Ok so now back to that one...
Mar 1 at 23:28, by Scratte
Why does this match?: ^..(?<=(?=1).)
 
@Yatin That is completely unrelated to self-referencing groups :)
And it will not help you to make a regex that only matches strings of length 2^n :)
 
1 hour ago, by Yatin
What does that have to do with this?
 
That one came about because I've seen it used a lot in complex regexes
Like this one (?sx) . (?<=^((?:.(?<=(?=^.*?((.) \\2?)$).*))*?))
Or this one (?x) | (?:(.) (?<=(?=^.*? (\1 \2?)$).*))+ (?<=(?=^\2$).*)
^ that one uses it twice.
 
:O
 
12:50 PM
Yeah.. those are from the "Advanced Regex-Fu". I think you need a little more basics before you go on a walk with those ones. I'm still trying to work out the first one.
 
I'll get there eventually ;)
 
This page about Regex Humor has this regex:
^(?=(?!(.)\1)([^\DO:105-93+30])(?-1)(?<!\d(?<=(?![5-90-3])\d))).[^\WHY?]$
The negative lookbehind has the construct that I'm confused about. Why does it need that last \d?
It doesn't need the other \d. That's just for extra confusion :)
I just took the joke-regex and simplified it into ^..(?<=(?=1).) because I want to understand why that last match is necessary.
 
Ok give me a minute to understand it
 
Ok. I'll be back in 10 min :)
 
Wait I don't know recursion
(?-1)
 
1:10 PM
Recursion means take the regex that is in that group and "put it here"
-1 means the previous group. +1 means the next group.
 
Ok
 
Only capturing groups count :).. I think.
 
Can I recursively call the group 0?
 
Yes.
 
Intersting
 
1:13 PM
(?0) or (?R) and lots of other syntaxes for the same thing :(
(?:[^\DO:105-93+30])(?-1) doesn't work. It has to be capturing groups.
 
So
(?-1) is unnecessary...?
 
@Yatin No.
 
Oh
So it matches the previous capturing group?
Previous to (?:[^\DO:105-93+30])
 
I just checked to see if (?-1) could only reference capturing groups or if non-capturing groups would be referenced too.
@Yatin No. It's not a backreference. It's a recursion.
 
Then what does (?:something)(?-1) mean?
@Scratte .. and?
 
1:17 PM
@Yatin This one I changed to make it non-capturing.. and it gave me an error for (?-1)
@Yatin ERROR is that it means :)
While (something)(?-1) means (something)(something) which is NOT the same as (something)(\1) or (something)(\-1) <-- I can't remember if one can do that.
 
Ok
BTW
(something){# of times you want to do it}
also works right?
 
@Yatin Yes :) That is the same :)
 
@Scratte Hun? Then why use recursion at all?
 
@Yatin I think you missed the point of that huge joke-regex :)
 
No, I mean in general... Can you give me a good example of where recession is needed..?
 
1:22 PM
^(a(?1)?b)$ :)
 
BTW does java support recussion?
 
Or (very long regex that only matches valid dated) something else (?1) :)
@Yatin Sniffle... NO :( :( :( :( :( Give me a kleenex-carton, please :'(
 
Yep :(
Neither does Python
 
I think maybe the repython module does.
But Java does support infinite lookbehinds :)
 
@Scratte Let me check
 
@hjpotter92 This is only available in the regex package not in std lib's re module. — Andy Hayden Jan 26 '17 at 23:47
 
> Supported by the optional regex library only.
So... It is supported :)
You should totally drop Java and learn 🐍 :p
 
LOL! But Java is the new way :) There's even a blog post that Java is better and faster than C++ :D
Anyway.. what does [^\DO:105-93+30] match?
 
Match all digits except 01359
 
1:36 PM
I don't think so :) You're missed that the - means an ascii interval
 
It is a little weird. ^\D means all digits
But then they add :- and +
:O
Sorry my bad
 
Yes, it does. It's a nice trick for languages that does not suppose intersection [\w&&[^\d]] or subtractions [\w-[^\d]]
 
Match all digits except 01356789
 
So.. what is left? :)
 
2
So I guess that is where the 2 comes in 42
 
1:41 PM
You listed 8 digits. If I recall correctly, there are 10 total.
 
Also 4
 
:)
So that character class is basically the same as [24]
Also.. part of the joke: What is 105-93+30? I mean if you're just calculating a result.
 
Lol
Nicely done :)
 
So.. you started out with:
^(?=(?!(.)\1)([^\DO:105-93+30])(?-1)(?<!\d(?<=(?![5-90-3])\d))).[^\WHY?]$
And you've reduced it to:
^(?=(?!(.)\1)[24]{2}(?<!\d(?<=(?![5-90-3])\d))).[^\WHY?]$
 
Yeah
 
1:46 PM
What does (?!(.)\1) do?
 
Checks if 42 isn't repeated?
No wait
 
:)
If I gave you aa, what will it say? What if I give you ab?
 
Checks if the same digit isn't repeated
 
Ah.. so now you have lookahead that checks that the same digit isn't repeated, and that the only digits that can be matched are 2 or 4, and the lookahead matches one of them twice.
 
Yeah so neither 2 or 4 should repeat
 
1:50 PM
taking out this part: (?=(?!(.)\1)[24]{2}).[^\WHY?]$
You can see what it matches on regex101 :)
Perhaps you can reduce the last character class too :)
You can actually also reduce the first part of this to just a simple lookahead.
I might have messed something up there.. because it seems to be not working :D
 
There are supposed to be 2 )
 
Argh!.. It is working. I just tested it on 22 :D
I just removed the last lookbehind is all.
And I substituted that joke-character class with [24] and instead of repeating it with (?-1) I just added a {2} to it.
 
@Scratte Yeah that part is ok
@Scratte I am working on this
 
@Yatin You can reduce (?=(?!(.)\1)[24]{2}) to a simple lookahead (?=something|somethingelse)
 
Give me some time :)
 
2:02 PM
No worries. Tell me in words what you already said about it :)
Or.. what two characters can this match [24]{2} ?
 
22 24 44 42
 
Are some of them excluded by (?!(.)\1) ?
 
Yep I though so
22 and 44
 
So what is left? :)
 
24 42
 
2:08 PM
So.. That's the same as (?=24|42), no?
 
Yep... but... why?
Guess it is part of the joke 😅
 
Of course :)
(?=24|42).[^\WHY?]$ What about that last class?
@Yatin I think you switched out the wrong part.
I removed the lookbehind completely. That one is a killer.. I'll take that last.
 
^(?=(?=24|42)(?<!\d(?<=(?![5-90-3])\d))).[^\WHY?]$
 
Yes. What does the last .[^\WHY?]do?
 
It matches a single (any) charecter and then matches spaces/line breaks etc
 
2:13 PM
You mean [^\WHY?] matches anything not in there, right? Including control characters and line breaks.. and whatnot :)
 
Yeah
 
But what do you have from your lookahead? Does it matter if it matches the \a bell control character? :)
 
I didn't understand..
 
@Yatin You have a ?= too many in the beginning there. :)
 
What should it be?
 
2:19 PM
@Yatin ^(?=24|42).[^\WHY?]$ this lookahead says: Start at the beginning of the line. Only if the next two characters are either 42 and 24 can we proceed. The .[^\WHY?] then goes to pick up those characters.
 
Oh ok
 
After the lookahead, you're back at there you started the lookahead. It doesn't ever eat the string. It can put stuff into a group, but it never moves your cursor. When a lookaround is over, the cursor is right were it was.
 
Yeah but the .[^\WHY?] captures it
 
@Scratte The lookahead doesn't care if we're at the beginning here. It's not part of the lookahead :)
@Yatin Is there any way that will not capture either 24 or 42?
 
No... It should...
 
2:23 PM
Is it the same as ..?
 
..
 
dot dot :)
 
dot dot
 
Is ^(?=24|42).[^\WHY?]$ the same as ^(?=24|42)..$ ?
 
Yea
 
2:24 PM
So.. Now for the killer..
You've reduced the overall regex to:
^(?=(24|42)(?<!\d(?<=(?![5-90-3])\d)))..$
 
Yep
(?<!\d(?<=(?![5-90-3])\d))
 
Yes.. that. Note that you are inside your lookahead, and the local lookahead cursor has moved and you now have either 42 or 24 behind you.
 
Yep
So now I look behind, and see if the first character is 4
Only 42 does that
 
No.. that's not what it does.
 
Ok wait
 
2:28 PM
Lets change it to a positive one first, because that's much easier for us humans:
(?<=\d(?<=(?=[5-90-3])\d))
 
Oh wait
(?![5-90-3])
 
Everything is positive now. So we can just focus on the movements of the cursor in there.
 
will check if the digit right next to the cursor is 4 or not
So for 24
 
This is a lookahead (?=[5-90-3]) inside a lookbehind of the one I'm confused about :)
^..(?<=(?=1).) <-- I reduced this to make it simple :)
 
My brain is starting to hurt :p
 
2:32 PM
But the lesson is that the last capture, the . or \d is needed.
 
Ok... now I am getting confused
 
(?<!\d(?<=(?![5-90-3]) \d )) if you remove this one, the regex is not the same.
@Yatin About the positive or negative lookarounds or about something else?
 
@Scratte Ok that I understand
 
@Yatin Funny.. :) Everyone else was puzzled about that.
 
I mean we have talked about it before... that you need something to catch that...
 
2:37 PM
^..(?<=(?=1).) will match a1, but ^..(?<=(?=1)) will not.
Ahh.. OK :) So we're good with that :)
 
@Scratte No wait... can you explain it please 😅
 
(?<! \d (?<=(?![5-90-3])\d)) This one seems to say: fail if the last character is a digit. But we know that it must be, so the rest of the expression must be evaluated. Because the evaluation is of everything, not just the parts. So \d is true. And only if the rest is true too, will it fail.
@Yatin LOL! That is too funny :D :D :D
 
I thought I understood it but I couldn't explain it to myself
 
@Yatin OK. We will start with the last one. The one that does not match a1
 
in SO Close Vote Reviewers, 3 mins ago, by TylerH
@bad_coder While doubt is related to 'question' (e.g. to doubt something is to question its veracity), it's less accurate to say you have a doubt when you simply do not know/understand something; having a doubt is appropriate when there is a claim/statement and you think you know enough to suspect the claim/statement is not true. Even so, if you only have one doubt, a native English speaker would typically say "I doubt this" rather than "I have a doubt about this".
@Scratte Yeah
 
2:43 PM
I made it simple with positive lookarounds :) So it says: Where you are now: Do not move yet, just Look back. Then inside it says: Where you are now: Look ahead and see if there is a 1 (in front of you)
 
Yes so
a1<--- I am here
So how is there a 1 in front of that?
 
The confusing bit is that it's inside a lookbehind.
And in ^..(?<=(?=1).) it's looking ahead before is takes the character :)
 
:O
God where does the regex engine start reading the regex?
 
But this is my understanding. Make sure that you are looking at a 1, when you take a character behind the current cursor. So the current cursor is at a1<-- here. And then go back and make sure you look at a one. Then take it. (Release it all when you leave the lookaround :-)
 
The start? the end? the inner most?
in SO Close Vote Reviewers, 1 min ago, by Hovercraft Full Of Eels
@TylerH: the use of "doubt" as a substitute for "question" I believe is part of the Indian sub-type of the English language. Please see: Can “doubt” sometimes mean “question”?
 
2:47 PM
@Yatin I told you :)
 
xD
@Scratte Ok :)
 
^..(?<=1) will work too.
I lost track of where we were with checking the 24 or 42 :)
 
@Scratte I am not entirely sure that I understand that lol
My brain is refusing to work 😂
 
@Yatin I can try again :)
 
Like where is the pointer?
What gets read first and how does it affect the pointer?
 
2:53 PM
@Yatin There are multiple. One for the eating parts and one for every lookaround.
The constant one is the one that consumes the string and put characters into group(0).
 
:O
 
It will never move when going into a lookaround. That's the way I see it anyway.
 
Yeah so the 2 .s should have positioned it after 24
 
When going into a lookaround a new cursor local to that lookaround is created. That will move inside it. It's like a local variable, and it will be lost when the lookaround is over. Only the main cursor is always there.
 
:O
 
2:58 PM
Let me explain it with something that is simple: ^(?=(24|42))..$
 
Wait this is easy...
I have an issue if the .. are before the lookahead...
 
1. Main cursor is at the beginning of the string
2. Lookahead. Lookahead cursor is matching the next two characters one character at a time. Before the lookahead is over, the lookahead cursor is standing after the two characters. If we added C after the alternative. The lookahead cursor would just move if there's a C in the string after it.
3. The lookahead is either a go (satisfied) or a no-go (unsatisfied).
4. If it is satisfies, the main cursor gets to eat the string where the regex starts here `..$`
Note that in this case the lookahead cursor "ate" the same characters that the main cursor did. It just never mattered that the lookahead ate anything, because it doesn't get to keep them.
^(?=(24|42))..$ is the same as ^..(?<=(24|42))$
First one says: If the next two characters... then eat them.
The second says: Eat two characters.. make sure what you just ate is.. :)
 
@Scratte So for the 2nd one the cursor is at the beginning again?
 
@Yatin No.. the second one the main cursor just ate two characters. After which is checked to see what it just ate. It doesn't move. The local lookbehind cursor is going to go back to check.
 
The local will walk backwards right?
 
3:08 PM
^..(?<=2)$ will eat two characters. Then a lookbehind will go see if the last eaten character is a 2.
 
And say if it had a lookahead within a lookbehind then? Will it go forward or behind?
 
@Yatin Yes. It walks backwards :)
 
Ok
 
@Yatin Yes :D :D :D That is what my confusion was all about :)
 
Oh boy. You don't know the answer?
 
3:10 PM
Yes.. I sort of do. You can make it look past your main cursor.
It only looks when it consumes something. (the lookaround cursor.)
 
🤔
 
^..(?<=(?=2))$ Here. the lookbehind cursor doesn't eat anything at all. Because the lookahead cursor is local to the lookahead only. The lookbehind cursor is unaffected by it.
So this one will check to see if there is a 2 in front of the main cursor only.
If you drop the $, you can test it on 982 :)
^..(?<=(?=2).)$ <-- here, we've added a character to the lookbehind. Forcing it to move. It must move back one character behind the main cursor. Then it needs to check if it's about to eat a 2.
That will work for 42 and 92
anything that is two characters and ends in 2 :)
 
Sorry I need to go... I will be back in less than 30 mins... Kinda important...
 
OK :)
 
3:26 PM
o/
@Scratte ok
@Scratte The main cursor? Not another local cursor for the lookahed?
 
@Yatin The main cursor does not move. The local cursor does not care where the main one is :)
The local cursor starts where it's parent is only.
Hmm.. that's not entirely true.
 
@Scratte where is the main at this point?
 
^..(?<=(?=2)) at the lookbehind start. The main cursor has eaten two characters, no? :)
 
Yes
So... why lookahead?
 
The lookbehind cursor will move depending on how many characters it needs to eat. It's not allowed to move past it's parent cursor (if I understand it correctly). If it it's told to eat two characters, it will move two characters and eat them and end at the point of the main cursor.
 
3:33 PM
Ok
 
So.. lets say I have this string: 9875. I want to eat two characters. Then I want to check if I just ate an eight that is before a seven :)
^..(?<=8(?=7))
 
:O
NOW it makes sense!
 
The $ killed it :D
I can also eat two characters and then I want to check that I ate an 8:
^..(?<=8)
Or.. the convoluted way: ^..(?<=(?=8).)
 
👍
@Scratte Oh god why
 
@Yatin Ask the joke-regex :D
^..(?<=8(?=7)) is also the same as ^..(?<=(?=87).)
 
3:39 PM
@Scratte I am not sure if I understand this one
 
and the same as ^..(?<=8)(?=7)
 
Can you give me an example on regex101?
 
@Yatin So.. you're at the point where I was when I started talking about my confusions :D
@Yatin I did.. :) I just used a 1 instead.. and the teststring was a1.
 
@Scratte What does this match?
 
^..(?<=8) means "I ate two characters. Is the last one I ate an 8?"
 
3:43 PM
Yes
 
^..(?<=(?=8).) means "I ate two characters. If I go back one character, I'll check to see if it's an 8 before I eat it (inside my check)"
 
Hm
 
The second meal does not affect the main cursor. Only the lookaround cursor eats it the second time.
^..(?<=(?=8).) is the same as ^..(?<=(?=8)8)
 
@Scratte And... it eats it so that (?<=) can get something right?
@Scratte Yeah that is fine
 
@Yatin ^..(?<=8) eats it too :) it's right there. I'll go back and eat an 8 :)
 
3:47 PM
so.... what will it match?
 
Only it looks easier to understand than ^..(?<=(?=8).)
@Yatin You tell me :)
 
@Scratte 88?
 
yes.. and? :)
 
8888
 
Yes, well.. it only eats the first two characters of the line.
How about X8? Or B8 or >8?
 
3:49 PM
Oh yeah
@Scratte Oh shot
 
Regex has a thing for those pesky little details that's so easy to miss :D
So.. you're ready for ..(?<!\d(?<=(?![5-90-3])\d)) :D
 
Just wait a second.
(?<=(?=8).) in this, is (?<=) executed first or (?=8).?
I belive it is (?=8).
The cursor is at:
88
__^ == main cursor
And you are telling it to lookahead
But there is nothing after 88
 
You're not looking at it in the most easy way. Think it them as function calls.
 
Ok
 
(?<=(?=8).) is lookbehind(lookahead(8),one character)
 
03:00 - 16:0016:00 - 20:00

« first day (287 days earlier)      last day (1150 days later) »