Seems very very very broken. The regex "[a]" apparently matches "crenel"
Regex Golf
141–150 of 189 posts
Re: Regex Golf
#142For Abba... Why doesn't (.)(.)\2[^\1] work? I thought backreferences matched the captured literal, so negating it would match? But this looks the same as (.)(.)\2\1...
You cannot negate a capture, only a character literal. A capture might only be a character but it is NOT a literal,
Re: Regex Golf
#143Re: Regex Golf
#144Re: Regex Golf
#145Me and a coworker totaled 3079 points. Anyone beat it?
Kudos to the author of the game, good job.
Re: Regex Golf
#146^(?!(..+)(\1)+$) Why does that work on primes? I got it by mistake when fiddling with the parenthesis locations but I was expecting to have to deal with xx separately.
Nice find. It works because it rejects "2 or more x's" repeated "2 or more times". So xx doesn't get rejected, but any multiple of that (xxxx, xxxxxx, ...) will be. The same way xxx doesn't get rejected, but any multiple of that (xxxxxx, xxxxxxxxx, ...) will be. You've solved it using the actual definition of prime numbers, no trickery needed. Well played. FYI, you don't need brackets around the \1, so can score 286.
- the first one is represented by the group (..+) it represents the number of occurrences n between 2 and +∞
- the second one is represented by (\1)+. We will repeat the first number m times, between 1 and +∞ times.
So the result of the multiplication is n*(m+1), which cannot be a prime. We just have to take the opposite with negative lookahead. It's very beautiful indeed.
See http://regex101.com/r/qN2fQ8 or http://www.regexper.com/#^%28%3F!%28..%2B%29\1%2B%24%29 to follow the above explanations.
Re: Regex Golf
#147(.+|)foo(.+|) Lol so awesome this. I oblige. Much love!
Powers: ^((((((((((x)\10?)\9?)\8?)\7?)\6?)\5?)\4?)\3?)\2?)\1?$ I feel like there's gotta be a sneakier way of doing this.
^(((((((((xx?)\9?)\8?)\7?)\6?)\5?)\4?)\3?)\2?)\1?$
(60 points)
Re: Regex Golf
#148Earlier quoted context omitted.
569pts: ([^31]0|31|[017]2|[03]03|[^1]4|(900|01|7)5|6|[48]7|[57]8|09)$
Originally had 568, then saw this and improved. :) 580pts: 00(0$|3|6|9|12|15)|[^0]14|.53|^3[^38]|55|43|23|9.7
5[54]|2[437]|00($|[369]|1[25])|^8[17]|^3[29]|9.7Re: Regex Golf
#149Re: Regex Golf
#150Earlier quoted context omitted.
^(?!.*(.)(.)\2\1) You may also need to fill in the places where it could be anything. The above worked on abba for me. BTW a double space indent then formats as code on HN I think.
Your approach scores higher, but it only matches the (imaginary) space before the "good" words. I went with: ^(?!. (.)(.)\2\1). $ with the thought that if I really wanted those matches I would want the whole strings. Fun game!
^(?!.*(.)(.)\2\1).*$
With proper formatting hopefully.