Forum Discussion
Error with Text.Trim
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.
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.
- DemoFour3 years agoContinued Contributor
ronrsnfld
thank you for your response.
I have !!! etc. at the end of sets of text, So you are saying that just having ! in the list will remove all of them.
There are all sorts of random punctuations as it is twitter data and people do strange things to put emphasis on the point.
Ok I will revise and see what happens- ronrsnfld3 years agoSuper User
Yes, even combinations. So if the string ends with "...!!!??", you can use trimList={".","!","?"} and it should remove all of them. If it doesn't, as I noted in your first tweet example above, it is because the character entered in trimList is different from the character actually there.
Your first line looks like it ends with "â€". However, it actually ends with "â€" where the very last character is code 157, and the pound sign, instead of being code 128, is actually a unicode character number 8364 (an HTML code). So you would have to include the codes for all of those particular characters in order to trim them off the end. Otherwise it will stop trimming at the first character from the end it encounters that is not in the trimList.
- DemoFour3 years agoContinued Contributor
ronrsnfld
I had postulated that the issue was with HTML code, I am not a coder so I was looking for lists of HTML etc. to try and think up a scalable list to use to remove all of this from the tweets.
That is a very good point and has helped me to find more of a resolve and understand the M language and using more advanced query editor usage. Thank you for your reply.