Hacker News new | past | comments | ask | show | jobs | submit login

.(C|HH)* should match against " " or against "A " or against "B" or against "ZZZZZZZ".

But this puzzle doesn't recognize any of those as valid.




That's not the case... .(C|HH)* matches with single character followed by any number of C's or HH's. So " " or "B" would work but in the puzzle the full line has to match so those aren't possible


Can you explain what you are seeing about "B" that does not match? Or about "_______"?


As you can see[1], the regex checker is based on the JS RegExp.match method. Each cell is always 1 character long (so, either a letter of some kind or an empty space). The str parameter for the check function is assembled by concatenating these cells together[2], so the input string for an empty line will look something like this: "_______"

Assuming an empty 7-cell row, the regex in question will match 7 times, once for each character. A result of multiple partial matches is not equivalent to getting just one perfect match, which is what the puzzle requires. Internally, the puzzle enforces this requirement by making each Regex rule require a full line match (see line 118: '^' + rule + '$').

Personally speaking, I felt like that was the most intuitive way to interpret the mechanics of the game, so I'm willing to give the programmer a pass when they slightly modify the regex rule prior to evaluation.

[1]:https://github.com/Jimbly/regex-crossword/blob/8b178f32eba37... [2]:https://i.imgur.com/PS0BmJ6.png


I agreed that "B" does match. However, the puzzle needs to match the full line and not just a substring so "ZZZZZZ" or "B " don't.


You have not explained how those are not matching the full line. I assert that they are. Show me actual correct code that says otherwise.


Even with the full line match, I can't figure this out.

R?(CR)*MC[MA]* is not matching for the full line RMCMMMMMMMMM

Why?


That line matches for me if I add it to the grid, though it breaks other lines.

Are you sure you're going the right direction? It should be going from the bottom left to the right (in the order of the the regex text).


Ah, thank you, that was it. I was assuming they started from the label.


Yeah it took some testing to figure out the direction.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: