How to remove some last data in a text?

I have text
Ex: AI Units consumedLast5.
In this I have remove “Last5” 5 is dynamic value and AI Units consumed is also dynamic value.
I need output value is “AI Units consumed”
Can any one help me?

HI @Vanitha_VS

Try with Regex expression

System.Text.RegularExpressions.Regex.Replace(YourString,"Last\d*","").Tostring

Regards
Gokul

Thank you.
and suggest me if any other solutions are there.

@Vanitha_VS

Use string Operations & remove that last word if it is constant if you know that word

Thanks
Varun

Hi @Vanitha_VS
Do you have any fixed word in your string? or maybe the number of letters you want to remove?

I have to remove Last5 but 5 is dynamic

Hey @Vanitha_VS,

As you said you want to remove the “Last5” where 5 is dynamic, if we will see the count of character are 5 so in that case you can use the below method.
image

Or you can use the regex method as explained by @Gokul001

Thanks,
Sanjit

Thanks you… It is working fine for me

1 Like

I have tryied using first Right function and Then remove function, it is working fine for me. Thank you…

1 Like

@Vanitha_VS

Use replace operation it will work, Str_Input is a variable

str_Input.Replace(“Last5”,“”)

Thanks
Varun

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