Hi there,
I am using Trimleft function to trim a string. However, it trims off one extra character.
To be specific, I have a field with value "BBC Kmlfsgees - LI6 - KE GAIN/LOSS", and I want to trim off "BBC Kmlfsgees - LI6 - " and keep "KE GAIN/LOSS". So I use
TrimLeft([Field1], "BBC Kmlfsgees - LI6 - ")
But the result turns to be "E GAIN/LOSS".
Does anybody know why? In addition, how to fix it? I know that Regex_Replace can do the job. However, can we fix the issue with TrimLeft?
Thank you so much!
Solved! Go to Solution.
The trim functions will trim off any set of characters that you’ve specified in the second parameter, not a specific string. It’ll continue trimming until it hits a character that wasn’t specified, which in this case the “E”.
try to use the ReplaceString() function instead.
I would consider the substring function as well
Substring([Field1], 21)
(I think 21 is the character length of you string to remove)
Oops! I thought I could accept two solutions! I accepted yours first then the post after yours. But then yours is not accepted as solution anymore. Sorry! I tried Replace and it works well. Thank you so much!
Thank you so much! I tried Substring and it works well! Though it should be 22 (there is a white space in front of KE...). Thank you so much for providing new ideas!
Actually I think that specifies the characters to keep.