Remove part of data from a particular cell

Hello all.

I have a small problem regarding retrieving data.
I am supposed to get a certain confirmation code from an excel file which I can using a string such as:
row(“confirmation code”).ToString
most confirmation codes come out like this “123-456” but however some added a little memo at the end like 123-456(abc).
Is there a way to remove the brackets and text so that it will only include the numbers and the “-”

Hi @dvn

you can do split function or use regex

Split("()".ToCharArray)

Thanks
Ashwin S

Hi @dvn,

You can try this, lets say your string “123-456(abc).” is stored in variable str.

so do like this, assign activity str(left side) = str.Replace("(","").Replace(")","")

Hope it helps. Thanks


Jatin

Hi @dvn

Please try :

strInput.Remove(7,6)

image


Mukesh

To get the required data -

Please add a condition to split only if the string contains “(”

If yourString.Contains("(") Then
   finalString = yourString.Split("(")(0)
else
   finalString = yourString
End If

Regards,
Karthik Byggari

2 Likes

If You want only numbers and -
then use Matches activity with pattern: “-*\d”
And then using String.Join(""MatchesOutPut)-----> for 123-456(abc) ans : 123-456

If the characters are fixed length then using Substring u can get
say Variable.Substring(0,7)----------> 123-456(abc) ans : 123-456

If at the end ( is added always then
Using Split U can get
Variable.Split("("c)(0)—>123-456(abc) ans : 123-456