Split function for same delimiter occurring twice in an excel cell value

Hi,
I have an excel cell value as Modify - Abc - Def as a role and need to extract Abc - Def value from it.
I have tried using role.split("-“c)(1) then the result was Abc and for role.split(”-"c)(2) the result was Def but I need Abc-Def as output.
Please help me on this, thanks in Advance

Hi @shiva_raj2 ,

Can you try this

Var1 = role.split(“-“c)(1)
Var2 = role.split(”-“c)(2)

Out = String.Concat(Var1,Var2)

Thanks!

Hi @shiva_raj2

Try like this

role.split({"-"},2,StringSplitOptions.None)(1)

cheers

In addition to:

works fine, thank you

1 Like

works good, thank you

It worked, Thanks

1 Like

What if i have Modify - Abc - Def (US) as a role and i need only
Abc - Def
How to split that

@shiva_raj2

role.split({"-"},2,StringSplitOptions.None)(1).Split({"("},StringSplitOptions.None)(0)

cheers

will this work even if i dont have “(” in role, because for some roles it is having and for some it is not there. I am confused.
example: Modify - Abc - Def (US) and Modify - Abc - Xyz
In both i need Abc - Def and Abc - Xyz. Both are present in the same list

@shiva_raj2

Yes
image

worked, thank you so much
:slightly_smiling_face:

1 Like

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