Regex Golf
131–140 of 189 posts
Re: Regex Golf
#132Re: Regex Golf
#133Earlier quoted context omitted.
Just to follow my thought pattern. I start with (.)(.)\2\1 Now to invert I change it to (?!(.)(.)\3\2) As you say, the negation matches an empty string. So I put on anchors: ^(?!(.)(.)\3\2)$ But now it matches nothing. I'm not even sure what that regexp says. The entire string is a negation? Would anything match that regexp? I see elsewhere on this page that the answer involves putting in an extra dummy character, pu…
^(?!.*(.)(.)\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.
I went with:
^(?!.(.)(.)\2\1).$
with the thought that if I really wanted those matches I would want the whole strings.
Fun game!
Re: Regex Golf
#134Glob (333) without cheating (replace ⁕s with asterisks, they get turned into italics): ^(\⁕?)(\w⁕)(\⁕?)(\w⁕)(\⁕?)(\w⁕) .⁕ ((.(?!\1))+|\1)\2((.(?!\3))+|\3)\4((.(?!\5))+|\5)\6$ Edit: ((.(?!\1))+|\1) is used to conditionally match .+ iff a * has been found. .(?!\1) Matches any character if it is followed by \1. When * has been found then it matches no character, when * is not found it matches every character. Edit 2: Fo…
le[^*]|co|ito|dr|^p|su|gi|nr|hw|fa|[eo]b|ide
Glob 376 although it isn't pretty and better may be possible.Indent two spaces with a blank line above to avoid code mangling.
Re: Regex Golf
#135Does anybody know how to do math with regex? (triples) And conditionals don't seem to work?
My guess is that 147 must appear the same number of times as 258, but I'm not sure if that's even expressible in regexp.
Re: Regex Golf
#136Why 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...
Re: Regex Golf
#137Earlier quoted context omitted.
Therefore, the score it provides should be a running tally of how many characters you've used to make it match the scoring system of golf; which is the lowest number of strokes wins. The scoring system for this is incremental which is the opposite of golf. A proper scoring system with this would provide a character limit (par) for each section and the goal would be to write a shorter regex formula to complete the tas…
I don't get what this is all about. The title was (most probably) derived from Code Golf, which is a competition in coding something with as few characers as possible. Code Golf was derived from Golf, where you want to use as few turns as possible. The score going up and not down, which is done because you get more points the more objectives you fulfill, does not change the objective of this game or what it is based…
This game is the opposite, meaning the higher the score the better.
This has nothing to do with the objectives of the games in question, just the scoring method.
To make the sport of golf have a similar scoring system as this game you would grant ten points for every stroke under par, deduct ten points for every stroke over par, and deduct one point for every penalty stroke.
Re: Regex Golf
#138For 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...
Re: Regex Golf
#139For 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...
Re: Regex Golf
#140Seems very very very broken. The regex "[a]" apparently matches "crenel"