How can I achieve a repeated string match in programming?