strings.Index for multiple substrings?

I want to answer the questions:

  • at what index, if any, is substring A located in my LargeString ?
  • at what index, if any, is substring B located in my LargeString ?
  • at what index, if any, is substring X located in my LargeString ?

I could call stirngs.Index for each of my substrings. But can it be done better ? I mean could the Knuth-Morris-Pratt or the Boyer-Moore algorithms, be adjusted so that they more efficiently search for multiple substrings together ?

Is this already done, any libraries, has anyone here encountered this ?

Have you found any Go implementation of it ?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.