Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What does "full match" mean? Either it matches or it doesn't.


I think some people may have thought you just have to match any substring within it, so I was clarifying that the whole line has to be a match.


Some people would be correct to think that. That is what those regexes mean. If you are secretly prepending a ^ and appending a $, then you are not using the regex displayed.


Sorry, but you're wrong. There's nothing about regular expressions that means you have to use them to search for matching substrings. That's just one particular operation that uses regular expressions. It's not a quality inherent to regular expressions themselves. There are many different operations you can perform with a regular expression besides a substring search.

Python, for example, has a fullmatch method.[0]

libicu's matches() function returns true "if the pattern matches the entire string, from the start through to the last character."[1]

PCRE has various flags that change what it means for a regular expression to match, including PCRE2_ANCHORED and PCRE2_ENDANCHORED. Used together, these options would require a full match with no change to the regular expression itself.[2]

0. https://docs.python.org/3/library/re.html

1. https://unicode-org.github.io/icu/userguide/strings/regexp.h...

2. http://www.pcre.org/current/doc/html/pcre2api.html#SEC27


Another way to describe this could be that the meaning here is inherently ambiguous between "is-a" and "has-a", but the puzzle only makes sense (and only has a solution) if you interpret as "is-a".

In Mystery Hunt puzzles, which this originally was, "we have to interpret this in a way that would allow there to be a meaningful and unique solution" is not only a perfectly legitimate form of reasoning, but often necessary!

It's not really exactly the same kind of reasoning, but in a puzzle I wrote a year before this for the same event

https://www.mit.edu/~puzzle/2012/puzzles/into_the_woodstock/...

you could look at it and say "hiragana is only ever allowed to be used to write Japanese!!!" but insisting on that rule (much as it applies in most situations) wouldn't give the puzzle a meaningful solution. :-)

Maybe a closer equivalent would be that in this year's Mystery Hunt, there was a puzzle using a set of variant Hashiwokakeru (Bridges) logic puzzles. There were hints about which rules were changed but it wasn't stated whether the rule changes applied individually (one puzzle each) or cumulatively (when rules get changed, they don't change back afterward), or some other way. So, it was necessary to make assumptions about what was meant and see whether they allowed a solution. That's typically considered fair and appropriate throughout Mystery Hunt-land.




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

Search: