$str = 'Test case 1 Test case 2 Test case 3 '; while($str=~/\s*(.*?)\s*<\/c>/){ print $1; }