Trim issue

Hi, How can I trim the string always from : I need the left part.

This is my string.

System.Data.DuplicateNameException: A column named ‘House Number’ already belongs to this DataTable. Sytem exception error in the excel data table only.

I want the string after : till Data Table alwasy.

Expected Output

A column named ‘House Number’ already belongs to this DataTable

@Palaniyappan

Fine thats possible
if the input is
str_input = “System.Data.DuplicateNameException: A column named ‘House Number’ already belongs to this DataTable. Sytem exception error in the excel data table only.”

then
str_output = Split(Split(str_input,": “)(1).tostring,”.")(0).tostring

Cheers @balkishan

1 Like

Thanks so much Palani

1 Like

Hi @balkishan,
don’t get me wrong, I’m a big fan of Split. But ever since the 2018 update where the function for ufathomable reason was updated/removed, I use:

str_Input.Substring( 0, str_Input.IndexOf(":") )

instead. It’s a bit faster and you won’t have to work an array of an array (which is doing much marshalling in the background) to get the left side.
You must, however, be sure that there are more than 0 chars and there is a “:” in the string. Otherwise it will runtime error with capital letters :slight_smile:

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