The Geppy String: Regex vs Iteration
Regular expressions are the right tool to use for this kind of test.  However, if you are going to use a regular expression to find lonely g characters, then you should use negative lookbehind and lookahead assertions instead of the negated character class [^g].

def geppy(str)
  !/(?&lt;!g)g(?!g)/.match(str)
end