How to cut off cell's text with specific mark? such as "("

Hello.

I want to change cell’s text with activity “for each”

apple(fruit)
rice(grain)
banana(fruit)
steak(meat)

there is a column like that.
I want to get text without text in “()”
only apple, rice, banan, steak…

How can I get the values?

Hello hoseongwon,

You can try to do it with Regex and take everything until “(” should look like this:

^[^\(]+

1 Like

@hoseongwon

Inside the for each row in datatable/for eqch row in excel activity…use a assign activity as below

Currentrow("columnname") = Currentrow("columnname").ToString.Split({"("},StringSplitOptions.None)(0)

If use for each excel instead use currentrow.Field("Name")

Hope this helps

Cheers

1 Like

Hi @hoseongwon ,

You could also try with Regex Replace :

Regex.Replace("apple(fruit)","\(.*?\)","")

image

1 Like

Hi @hoseongwon ,

Check this below code,
strVar(String type) = System.Text.RegularExpressions.Regex.Match("banana(fruit)",".*(?=\()", System.Text.RegularExpressions.RegexOptions.Multiline).Value

Screenshot:

Hope this help might you :slight_smile:

6 Likes

Thank you! it really works.

I chose your answer because the most simple.

1 Like

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