Remove strings from ()

I have a string which looks like below
Names (as of)
College (University)
Class (abchdf)

I want to remove everything in the brackets and convert this string into array of strings.
The above mentioned is a single string.
How can achieve this ?

Hi @Abc_Xyz1 ,

Could you check with the below Expression :

Split(Regex.Replace(yourStringVar,"\(.*?\)",""),Environment.NewLine).ToArray

Maybe Regex Split is better suited for this case :

Regex.Split(Regex.Replace(yourStringVar,"\(.*?\)",""),"\r?\n").ToArray

Hi @Abc_Xyz1

You can try with Regular expression

System.Text.RegularExpressions.Regex.Split(System.Text.RegularExpressions.Regex.Replace(Yourstring,"\(\S.*\)",""),"\n").ToArray

image

Regards
Gokul

When I use this array in for each loop, the first iteration has all 3 elements.
Basically it is taking the 1st item as all 3 mentioned elements.
1st item= Name
College
Class

@Abc_Xyz1 ,

Were you able to check with the expression mentioned above ?

Yes still the whole is taken as one item instead of 3 strings in array

@Abc_Xyz1 ,

Could you provide a Screenshot of the implemented part ?

Maybe also check with the Debugging Panel and send it’s Screenshot here.

Hey @Abc_Xyz1
image
Check this out hope this helps you
array String.zip (68.7 KB)
Cheers.

4 Likes