Amazon Interview Question

find valid strings in a string