i am trying to create a function which will delete...
# cfml-general
g
i am trying to create a function which will delete the repeated word, but somehow its ending up showing again https://cffiddle.org/app/file?filepath=1c43f4ed-e92d-4d49-89e9-4f84a28c9251/9ca40e6[…]8f5-86fb-286d06cc9e64/d8d87a84-52f4-49a2-8389-d7692b5c8aa1.cfm andyone can shed some light on it
b
I'd start by debugging your inner loop where the words are split on the space character so you can see which word is being evaluated. It would help to output each word being checked as well as the array at the time it's being checked. Use that to seee if you can spot any defects in your logic.
t
I think the issue is that
Rejected
and
Rejected,
are not the same word.
(line 9, you split on space only)
g
ok, so a Multi delimiter like space and comma should be there then and it should end up the next one starting with -
q
gsr -- have you thought about using RegEx to do this? I know that's not what your question is, but loops like this really make my head (and the compiler's) hurt.
❤️ 1
b
If what you're searching for is words, you might be better off using a regex to replace non alphanumeric characters first, and then do your check for whether you've seen that word or not.
Another option is to convert your array to a list, then use
listRemoveDuplicates
to remove duplicate list entries, then cast back to an array. Performance on large arrays may suffer, but it might be an option.
❤️ 1
g
the listremoveduplicartes worked well in this case
Thanks