Forum Discussion
Erase words (from a dictionary) in paragraphs across multiple cells
- Nov 25, 2022
'e' is assigning a name to a parameter in the array that MAP will check. Essentially, what MAP allows you to do is to perform a calculation on each 'element' in an array. If you study MAP, you may also look into the functions mentioned here:
Announcing LAMBDA Helper Functions (microsoft.com)
I've updated the sample to account for those anomalies. CheckWords is a LAMBDA designed to pull out words found in Column A.
'CheckWords 'This function 'explodes' a cell converting it to an array. MAP replaces words found in the Words list with a blank. =LAMBDA(element,TEXTJOIN(" ",,MAP(TEXTSPLIT(element, " "), LAMBDA(word, IF(ISNUMBER(XMATCH(word, words)), "", word)))))CheckWords is then run on each 'element' within the paragraphs array.
=MAP(paragraphs,LAMBDA(e,CheckWords(e)))
It sounds like you have access to the latest functions so this might work for you:
=MAP(paragraphs,LAMBDA(e,TRIM(TEXTJOIN(,,TEXTSPLIT(LOWER(e),LOWER(words))))))
- Mark_DekeyserNov 25, 2022Copper Contributor
Patrick2788 Thank you Patrick!
That's (almost) the solution I'm looking for: I'd like to erase full words, so not to erase 'bed' from 'embed', but I hope to figure it out from here.
So, I have to learn two new Excel functions, being MAP and LAMBDA.
After a quick scan of these functions; could you please explain the parameter 'e'; I don't get it...
Thank you!
- Patrick2788Nov 25, 2022Silver Contributor
'e' is assigning a name to a parameter in the array that MAP will check. Essentially, what MAP allows you to do is to perform a calculation on each 'element' in an array. If you study MAP, you may also look into the functions mentioned here:
Announcing LAMBDA Helper Functions (microsoft.com)
I've updated the sample to account for those anomalies. CheckWords is a LAMBDA designed to pull out words found in Column A.
'CheckWords 'This function 'explodes' a cell converting it to an array. MAP replaces words found in the Words list with a blank. =LAMBDA(element,TEXTJOIN(" ",,MAP(TEXTSPLIT(element, " "), LAMBDA(word, IF(ISNUMBER(XMATCH(word, words)), "", word)))))CheckWords is then run on each 'element' within the paragraphs array.
=MAP(paragraphs,LAMBDA(e,CheckWords(e)))- Mark_DekeyserNov 25, 2022Copper ContributorWow... That's not only next level, that's simply amazing 😉
Thank you so much! I'm gonna study now 😉