Out of curiosity, what does your input look like? If you could give an example that shows what the string you're searching looks like, particularly those that contain Gi or Gt there could be other approaches to consider.
This is now bugging me. :-) I can't see what the for loop is doing. I really need to see the data. Give me the data. :-)