Earlier quoted context omitted.
390: de|eat|fa|rr|ow|[rl]o|^p|[cd]$
Glob 392: ^p|c$|[wrbc][npbro]|ai|fa|il
Regex Golf
181–189 of 189 posts
Re: Regex Golf
#182Re: Regex Golf
#183Re: Regex Golf
#184Re: Regex Golf
#185Re: Regex Golf
#186Earlier quoted context omitted.
improved, gives 80 ^(x|(xx){1,9}|x{32}|(x{64})+)$
I tried to get rid of those redundant ^ and $ but it somehow didn't work. I probably forgot to put it all inside one group.
Re: Regex Golf
#187Earlier quoted context omitted.
Regex explained: (...) # Match exactly 3 (the dots) characters and save them as a group (the parenthesis) .* # Match any character (the dot) 0 or more times (the asterisk) \1 # Reuse the first group
backreferencing is new to me, but why this: (...).*(...) isn't working !! ain't I back referencing the first group which is (...) ?
You're reusing the regex and not the match. Back referencing essentially means that you'll match whatever is matched the first time, rather than reusing the regex pattern.
I hope that made a little sense. Grouping, capturing, matching and backreferences is part of what makes regex tricky and very powerful. You might want to use some of the online tools, which can help explain the regex visually.
Re: Regex Golf
#188Earlier quoted context omitted.
I tried to get rid of those redundant ^ and $ but it somehow didn't work. I probably forgot to put it all inside one group.
They are not redundant. Any string of one or more exes is going to constrain a substring of exes of length 2^n (consider n=0 for a trivial proof), so you do need those anchors!
Re: Regex Golf
#189Earlier quoted context omitted.
backreferencing is new to me, but why this: (...).*(...) isn't working !! ain't I back referencing the first group which is (...) ?
It isn't working because (...) is just matching 3 characters. What your regex is saying, is basically: Match any 3 characters, then any character 0 or more times, then any 3 characters. You're reusing the regex and not the match. Back referencing essentially means that you'll match whatever is matched the first time, rather than reusing the regex pattern. I hope that made a little sense. Grouping, capturing, matching…