Trimming Text

How to trim first and last letter in a sentence?

Example: I have a sentence that start and end with % , so i want to trim % from both start and end of the sentence.

Hi @Anusuya_R ,

Could you give a try on the below Expression :

yourStrVar.Trim("%".ToCharArray)

@Anusuya_R ,U can try.

string_len = YourString.Length
YourCutString = YourString.SubString(1,string_len-2)

Nope… It didnt work

I have set of rows with particular value.Not all the row value begins with $ so i think it wont work

@Anusuya_R ,Ok,there are have fixed number of words sames like “$”?Or it is random?

Hey!

Try like this

Input.Replace("%","").ToString.Trim

Reference:

Regards,
NaNi

Hi @Anusuya_R ,

Could you show us How you have implemented it ?

In Addition, also give a try on the below :

yourStrVar.Trim.Trim("%".ToCharArray)

Do note that % was the symbol that you have mentioned earlier that you want to remove.

What is the actual set of characters that you want to Trim?

Hi @Anusuya_R
Assign InputString = InputString.Trim(" “c,”%"c)
This will remove empty spaces and % in start and end.
Try this and Please let me know if this worked or not

1 Like

Perfect… Its working !!!

1 Like

Hi,

I have a point to add here, If we are using Replace for ‘%’ then it will replace all % in the text. But If we used trim then with character then it will remove only in start and ends.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.