Yea, a regexp might perform better here by reducing the number of times we walk the string.  But would the regexp be easier to read and maintain?  Probably not.

I actually can't think of how to write the regexp for this method.  Its pretty hideous.

This method is only called once per incoming HTTP request, and in servers like Gerrit Code Review, its actually not even going to be used.  (Gerrit will override it with its own database lookup.)  

Its really not worth trying to optimize this in exchange for reduced readability.