I really do not understand your test cases. Please post code that we can run and duplicate both your successes and your failures (and know the difference). Note how my example used Test::More to show that my function did exactly what I expected (Perhaps not what you wanted, but you can tell). You have a good start with your pass and fail test cases. Unfortunately, we cannot tell if they are single or doubly quoted strings or if you intend to include newlines. The same thing applies to your expected results. Are backslashes literal or are they escapes? The result fragments you posted are much harder to test than complete strings.