
Show HN: RegEx Face Off – Beat your friends with regular expressions - impostervt
https://www.regexfaceoff.com/
======
netsec_burn
Sorry, this will be a negative review. This is easily the most frustrating
game I've ever played. I can't test parenthesis because it tells me my time
'ran out' with 45 seconds on the clock. I could barely type 4 or 5 characters.

Edit: There are also XSS issues with the player name, you can execute
Javascript in the other player's window. That's not good. I confirmed this
since an image I scripted to load via HTML (<img src=) was visited by a Mac
user. I use Linux.

POC player name:

    
    
      Rick<audio style="width: 0px; height: 0px;" controls autoplay><source src="http://vignette3.wikia.nocookie.net/rickroll/images/d/d0/Rick_Astley_-_Never_Gonna_Give_You_Up.ogg/revision/latest" type="audio/ogg"></audio>

~~~
impostervt
The Rickroll should be fixed.

~~~
netsec_burn
Still there actually, but in a different place. There's another XSS, if you
just paste this in your solution:

    
    
      |<audio style="width: 0px; height: 0px;" controls autoplay><source src="http://vignette3.wikia.nocookie.net/rickroll/images/d/d0/Rick_Astley_-_Never_Gonna_Give_You_Up.ogg/revision/latest" type="audio/ogg"></audio>

~~~
impostervt
Ok, now THAT rick roll should be fixed

------
wwwigham
My strategy of "capture the last two characters of each input in the accept
group followed by $" hasn't failed yet, and is quick to input and requires no
thought. Though I wouldn't say I'm practicing any practical RegEx skills doing
so. :P

~~~
pepijndevos
My strategy was ^[].*[^]$ where you first fill in all the first letters of the
match words and then all the last characters of the skip group. Works fairly
well.

I'm not sure if there is a length limit, but I'm fairly sure I could come up
with a vim macro/regex that would allow me to copy the match words and make a
(list|like|so) within 45 seconds.

Give the time limit, it would be more fun to automatically let your strategy
compete. (maybe with a weight of length vs correctness) Write a function that,
given two arrays of words, return the best regex.

~~~
ygra
> Write a function that, given two arrays of words, return the best regex.

I've actually done that with code-golf in the past. I needed a regex shorter
than _n_ that would match what I wanted it to match, so I generated valid
regexes up to _n_ length and tested them. A bit brute-force, but eventually
saved me one character in the program.

------
umbrai_nation
There's definitely a bug in the timing. I feel like it's related to the
previous round. Whenever I finished a round early, the next round timed out
early.

Also, it should be revamped to always run the full time and award points to
the shortest regex. I regularly won rounds with entries like `foo|bar|...`
Easy to write, and requiring almost no skill.

------
marcoperaza
Is the game about regexes or finding letter patterns in words? The rounds I
played aren't realistic or particularly interesting uses of regexes.

------
swalsh
This game would be better if it was like a pacman style cave with random
letters or whatever, and you had to write a regex to get to the other side
without running into an enemy

------
zzzcpan
Some explanation of what to do and what flavor of "regex" syntax is accepted
would be good. I'm guessing it's a javascript syntax, but I don't really
remember how different it is from pcre, does it have lookahead/lookbehind
assertions and all that. Also cloudflare's free ssl doesn't work everywhere,
letsencrypt is better at that and also free. Had to open the thing in chrome.

------
natch
I know people have said this already, but just to update it, the site is still
giving 5 second timeouts.

Also when you are playing as anonymous against anonymous, when it says:
"anonymous wins" you don't know which of the two anonymous players won. Even
if the game says "you won" in the case where it was you, a new player doesn't
know that, so it still seems unclear. The anonymous players should be
differentiated in some way.. a number tacked on, for example.

Also when the round finishes, it shouldn't just show the regular expression
for two seconds and then clear. It should show it for long enough to let me
read it and think about it, with the data still displaying, and with a
continue button I can click when ready.

Also sadly I think long term this site will have trouble attracting matching
players. I expect it to only work during the peak of this exposure on HN.
Great idea though.

Finally you should scale down the data so there is less of it to read. You can
still make the challenges interesting with well chosen data. And you could add
capture and substitution requirements. Again, great idea.

------
drej
I'm a bit confused - I'm not sure I understand the practicality of this. I do
like challenging regexps, but I did not find them here. I thought the point of
code games is to practice a skill you could use in real life, but matching
random bags of words while avoiding other random groups of words isn't
something one would use regexps for.

Apologies if I misunderstood the point of this.

------
logicallee
Spoiler warning: super-strategy below.

Not a bad idea but since there's no penalty for long strings I can win pretty
much instantly by treating it as a typing test and typing a short (probably-
unique) substring from each match separated by |. It'll get me an instant-win
but if for some reason it matches some non-matches I make it a little longer.
Here's a screen grab of me winning with this super-strategy. on this run for
some reason you'll notice there's a bug at the end but normally it just lets
me win with no chance for the other person to score. I'm not sure how you
could address this... If you keep it this way it just becomes a typing test...

[http://tinypic.com/player.php?v=jf88pe%3E&s=9](http://tinypic.com/player.php?v=jf88pe%3E&s=9)

~~~
SnaKeZ
It's more comfortable / fast make a JS that concatenates the strings (class
.match) with pipe separator.

~~~
logicallee
but I didn't "cheat" \- I literally typed by hand a regex for the matches but
not the non-matches. (Exactly as was asked.) I guess a way to fix this would
be to make it like "regex golf" where there is a fixed time but the shortest
overall regex wins... It could also be defeated if most substrings of each
match were also in the things to avoid. For example if you're supposed to
match cat but avoid catch then my strategy would be defeated. I would have to
addd ^cat$ -- which wouuld cost me time and characters. :)

------
linusthebear
Agreed, awesome idea, needs a few bug fixes. Perhaps a description of the game
mechanics. Some patterns match inaccurately, and I am also experiencing
running out of time with 30+ seconds on the clock, as well as not getting
credit for correctly matching patterns. I had fun nonetheless.

------
nothrabannosir
Nice idea! Unfortunately, here's how to solve pretty much any game in <3sec:
firstword|secondword|thirdword|...

you can usually stop typing every word after ~3 chars (no other ones will
match).

------
impostervt
This is a little side project I made to learn about Web sockets. Each question
consists of a "match" pattern and a "skip" pattern, and then looks up words on
wordsapi.com to match those patterns when the question is generated.

It was hard thinking up patterns, so if you have ideas, please let me know.

~~~
marcoperaza
Cool concept, but I think it'd be infinitely better if the challenges were
more realistic/interesting. E.g. matching dates in a particular format, but
not another similar format.

------
readme
Game's fun but there's a problem when sometimes the time runs out prematurely.
If it didn't do this I'd say 5 stars well done.

------
impostervt
Maybe I need to add a "I give up" button to the question, and if each player
hits it, move on to the next question.

------
bharatkhatri14
Been ORing the first three characters of every to-match string. No one has
beaten me in 15 games.

------
SnaKeZ
Beautiful game but be care of cheaters, you can win just using DevTool (I
tried and works well).

------
DvdGiessen
Really cool, enjoyed playing it for a while. Challenges you to practise your
regex golf[1] skills. :)

There seem to be some bugs with the timing mechanisms, probably some JS
timeouts aren't properly reset, causing weird game behaviour like running out
of time mid-game (the countdown still displaying 10+ seconds). Also correct
answers aren't always acknowledged (all icons show the answer to be correct,
however it doesn't result in that player winning the game). :)

[1]: [https://xkcd.com/1313/](https://xkcd.com/1313/)

------
thealistra
the app works to fast and I as a user get confused. It should show who won,
with what match at the end of the round for a longer period of time

