How to saperate values wit comma or semicolon

Hello,

we are fetching details from jira tikcet using api.
In the ticket there is on euser field which contains usernames and when user creates the ticket they enter in below manner-
ex 1 - abc,pqr,xyz or
ex2- abc ,pqr;xys or
ex3 - abc;pqr; xyz

for no i can remove sapce by trimmimg and if only case like ex1 i a able to get commasaperated values with below code -
i am getting as array and splitting with comma-

but my requirement is automation should work for ex2 and 3 as well where ; and , combination is there and it should slip properly with trim.
how can i achive this?
as for now only comma saperte i am doing then it is taking pqr;xys and abc;pqr; xyz as one one user.

help me on same

Hi @Mathkar_kunal,

Use the below expression:

arr_Users = str_Users.Split({","c, ";"c}, StringSplitOptions.RemoveEmptyEntries).Select(Function(x) x.Trim()).ToArray()

Thanks!

Hi @Mathkar_kunal

You could start of by replacing the comma with a semicolon (or the other way around) before you split.

Assign arr_Users = str_Users.Replace(",",";").Split(";", StringSplitOptions.RemoveEmptyEntries)

Regards
Soren

1 Like

Hi,

FYI, another solution:

strArrayVar = System.Text.RegularExpressions.Regex.Split(strVar.Trim(),"\s*[,;]\s*")

Regards,

1 Like

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