3 ms·
Agreed. Some of them can be simplified quite a bit, which leads to a lot of clutter. For instance, (XHH|[^XH])* is equivalent to just .* EDIT: It look
by ryangittins 6y ago
Agreed. Some of them can be simplified quite a bit, which leads to a lot of clutter. For instance,
(XHH|[^XH])*
is equivalent to just
.*
EDIT: It looks like I read the regex wrong. I guess I need to do the puzzle after all!
- deleted 6y ago[deleted]
- anderskaseorg 6y agoNo, (X|H|H|[^XH])*` or ([XHH]|[^XH])* would be equivalent to .*, but (XHH|[^XH])* requires that XHH appear consecutively in that order whenever they appear at all.
- ladberg 6y agoThose are not equivalent, I think you're thinking of [XHH] instead of XHH.
- ryangittins 6y agoThanks, that's exactly how I read it.
- Guvante 6y ago("The sequence XHH" or "any character by X or H") repeated 0 or more times. Is not the same thing. It is "If any of X or H appear they appear in a sequence exactly matching XHH".
- rav 6y agoI found other patterns that I thought were unsimplified, but (spoiler alert) in the end it turned out that all of the seemingly-unnecessary details were important for the solution! E.g. [^C]*[^R]* LOOKS unsimplified, but it actually means that if the string contains an R, the preceding characters CANNOT be C.
- justusthane 6y agoOr if the string contains a C, a subsequent character can't be an R? Doesn't it really just mean a string can't contain a C followed by an R?
- DavidSJ 6y agoYes, those are three ways of saying the same thing. :)
- justusthane 6y agoNot really. Maybe I'm being overly pedantic, but my point was that the first two ways of describing it are overly specific and don't include all the strings that can be matched. Only the third option really describes all the possibilities.
- DavidSJ 6y agoWhat is an example of a string that can be matched which does not meet the first or second description?
- justusthane 6y agoSorry, you're right. I'm not sure what I was thinking.