Regex Golf
151–160 of 189 posts
Re: Regex Golf
#152Glob (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
#153Re: Regex Golf
#154Glob (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…
Glob 386 although not the cutest way to do it.
Re: Regex Golf
#155Glob (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.
^([wlpb]|c[hor]|do|re|mi|\*[pifvt]|\*er)Re: Regex Golf
#156Earlier quoted context omitted.
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…
From my quick read, Code Golf uses a similar scoring system as to the sport of golf, the lower the score the better. 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…
Regex golf is to code golf as paintball golf is to normal golf. Or something.
Re: Regex Golf
#157They might improve on those intended by exploiting accidental regularity in the corpus - though charmingly, the golf-cost of regex length helps combat this overfitting. They might also find genuinely cleverer solutions.
Re: Regex Golf
#158For "6. A man, a plan", I thought it was impossible to match palindromes with regex, am I wrong?
That said, 'regular expressions', as used in most programming languages, have extensions that extend the expressive power. One such extension is the matched group & backreference, used in other commentor's answers.
From a theoretic stance, these aren't really 'regular expressions', but that's what we call them in practice.
Re: Regex Golf
#159Re: Regex Golf
#160I like the idea, but words there seems to be pretty random. I can't figure out the pattern, not even talking about writing regex... :(
Read a) name of the puzzle b) the little help below the score. It gives out the pattern you should (not) look for. edit: Not in Glob. What is Glob about?
https://en.wikipedia.org/wiki/Globbing
I haven't figured out how to solve this with the parts of ERE and PCRE that I know. (I definitely don't know the entirety of PCRE.)
It's straightforward for me to write a substitution using regular expressions to create a pattern-matcher for a given glob (just anchor the ends and replace literal ? with . and literal * with .*) but here we have to do it inside a single regular expression.
I don't think there's a BRE solution if the number of stars is unbounded because I don't think this is a regular language.