var text = 'Rain and Spain'
text.match(/ai/gi)
// => [ 'ai', 'ai' ]