top of page



DataWeave programming challenge #3: Count palindrome phrases using the Strings module


In this post:


Try to solve this challenge on your own to maximize learning. We recommend you refer to the DataWeave documentation only. Try to avoid using Google or asking others so you can learn on your own and become a DataWeave expert!

💡 Tip: For this challenge, we encourage you to make use of the Strings module's functions.


Consider the following input payload (can be of txt format):

this is not a palindrome
Mr. Owl ate my metal worm
Was it a car or a cat I saw?
you're doing great!
Rats live on no evil star
what's taking so long?
Live on time, emit no evil
Step on no pets

Explanation of the problem

Each line of the input payload is considered a different phrase. Review each phrase and find those that are palindromes. Notice that punctuation, spaces, or special characters should not be considered to ensure a phrase is a palindrome.

For example,

  • Anna in reverse is anna - this is a palindrome.

  • 2020/02/02 in reverse is 20200202 - this is a palindrome.

  • Mr. Owl ate my metal worm in reverse is mrowlatemymetalworm - this is a palindrome.

After that, retrieve the character count of the original phrase. Including punctuation, spaces, and special characters.

For example,

  • Anna is 4.

  • 2020/02/02 is 10.

  • Mr. Owl ate my metal worm is 25.

Return the total sum of all the palindrome's character count.

Expected output

In this case, the expected output would be:


The result for each of the phrases (whether they're palindrome or not) should be:

  1. false

  2. false

  3. true

  4. true

  5. false

  6. false

  7. true

  8. false

  9. true

  10. true

  11. true

  12. false

  13. true

  14. true