Forum Discussion
Error with Text.Trim
Right, so the list needs to hold single text values. It has lots of multi-character values
Can you eloborate a bit please.
The list of Punctuatuation is below. I added the .. ... !! !!! !!!! becasue of the source tweet text containing this to try and fix the issue.
The list
= {" ", "~", ",", ".", "..", ". .", "...", "....", ".....", "?", "!", "!!", "!!!", "!!!!", "!!!!!", ", ", (", "), "[", "]", "{", "}", "%", "^", "&", "*", "+", "=", ":", ";", "|", "<", ">", "/", """, """, "\", """", "#(tab)", "#(cr)", "#(lf)"}
In the Raviv book, the text is all nice and neet of course, real world data is unpredictable and not following an easy format.
I did not think this would be such an issue, to learn some M and to try out some textual clean up and analysis for an upcoming project.
- HotChilli3 years ago
Community Champion
"...", "!!!!"
are multi-character strings.
"." or "!" are single character
- AlexisOlson3 years ago
Super User
HotChilli is correct. The Text.Trim function only takes a list of single characters.
For example, this does not work
But this does:
If you clean up your list to remove multi-character strings then it should work. For example, try this definition:
{" ", "~", ",", ".", "?", "!", "(", ")", "[", "]", "{", "}", "%", "^", "&", "*", "+", "=", ":", ";", "|", "<", ">", "/", """", "\", "#(tab)", "#(cr)", "#(lf)"}- DemoFour3 years ago
Continued Contributor
HotChilli AlexisOlson
Thanks guys, so the previous error I was getting because the column had multiple strings. That makes sense.
Can you suggest a robust way to remove the multi stings, or is it a case of manually using replace text for all combinations - I feel that this is not very scaleable, so may brake the query.
Thanks for taking the time to respond.- ronrsnfld3 years ago
Super User
What are you asking?
Text.Trim(Text, Trim) is going to remove all the characters in the Trim list from the beginning or end of Text. If your string ends with "!!!" and you have "!" in Trim, it will remove all of the "!"'s. You only need a single character listed.
If your use case is different, please clarify. For example, if the characters in Trim are not at the beginning or end.