Write a code to find the duplicate words in a string.
input string = "Big black bug bit a big black dog on his big black nose"
output:
Duplicate words in a given string : big black
Discussion posts and replies are publicly visible
Handling Unnecessary spaces:
a!localVariables( local!string: "Big black bug bit a big black dog on his big black nose nose ", local!data: split(local!string, " "), /* Handling null in case of unnecessary spaces */ local!list: reject(fn!isnull, local!data), local!result: a!forEach( items: local!list, expression: if( length(wherecontains(fv!item, local!list)) > 1, fv!item, {} ) ), union(local!result, local!result) )
Glad to see you here.
Try using this from next time for better readability.