Rob Pike's simple C regex matcher in Go
So fun story (to me in retrospect).<p>I had an interview at google years ago where I basically I was asked to come up with this on my own.  In my opinion, a terrible interview Q (per Kernighan&#x27;s blog, linked in original post, it took pike an hour or two alone in his office), and I bombed it.  It was either my just before or just after lunch interview and it stuck with me for the rest of the day and I couldn&#x27;t give my entire focus to the rest of the sessions.<p>anyways, after it was done, I found kernighan&#x27;s blog post and decided I should try to implement this in java as it will allow me to even get some practice with things like junit and more experience with object oriented programming as I had been living in the C world at that time).  so I did, but I then found this regular expression page ( <a href="https:&#x2F;&#x2F;www.regular-expressions.info&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.regular-expressions.info&#x2F;</a>) and learned many more things about &quot;regular expressions&quot; that i hadn&#x27;t learned in school (because they aren&#x27;t regular) and wondered if I could extend pike&#x27;s simplicity to them in a relatively simple manner.  So I did.<p>which I created this <a href="https:&#x2F;&#x2F;github.com&#x2F;sjpotter&#x2F;regex" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sjpotter&#x2F;regex</a>.<p>Not meant to be &quot;performant&quot; but meant to be educational to me and perhaps others.<p>Then when I was learning go, I rewrote it in Go.  I did things that are not &quot;normal&quot; go patterns (i.e. using panic and recover to make error handling cleaner (in my opinion, if an error path is simply if (err) { return err } all the way up, I personally think panics&#x2F;recover at the top can be cleaner, but it seems most disagree), but it was educational on how to rewrite my java code to an object oriented style in Go and to explore the limitations of interfaces and how one might get around them (also perhaps in ways that go against what might be considered proper go programming)<p><a href="https:&#x2F;&#x2F;github.com&#x2F;sjpotter&#x2F;regex-go" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sjpotter&#x2F;regex-go</a><p>though now that I look at that repo, wondering if all the work was done elsewhere and then I just pushed a single commit there, might need to go back and look at it