Array of item with double quotes

hi,

I have an array of string item and I’m passing that from config,I want all item to be enclosed with double quotes,

Ex:
Input

string = a,b,c,d

Output = “a”,“b”,“c”,“d”

How can I get the output as above

Hi @yashashwini2322 ,

Could you let us know if the Output Expected is a String or an Array ?

I’m passing a,b,c,d in config and
the output I want as below

Str=“a”,“b”,“c”,“d”
Where as str is string variable

@yashashwini2322

  1. Assign Activity:

    • Left side: Arrystring (the array of strings you have)
    • Right side: Split(config(“Arrystring”).ToString, “,”)
  2. Assign Activity:

    • Left side: EnclosedArray (an array of strings)
    • Right side: New Array of String (Arrystring.Select(Function(x) “”“” + x + “”“”).ToArray())
  3. Log Message Activity (optional):

    • Output: String.Join(“,”, EnclosedArray)
  4. Save and run the workflow.

Not using array, I’m using string variable

Input:
string = a,b,c,d

Output:
Str = “a”,“b”,“c”,“d”

@yashashwini2322 ,

Maybe we could also check with Regex Replace :

Regex.Replace(strText,"([^,]+)","""$1""")

image

We would also require to have the imports done to use it without the Namespace :
image

1 Like

You can try this way

@yashashwini2322

Hi @yashashwini2322

Try this

String.Join(",", Array.Select(Function(item) """" & item & """"))

You can try this Xaml

Xaml : - Double Quotes.zip (1.5 KB)

out put : -

image

@yashashwini2322

It’s throughing an error

@yashashwini2322

string.Join(“,”,inputstr.Split(“,“c).Select(Function(x) “|”+x+”|”).toarray).Replace(“|”,Chr(34))

try the above expression

cheers

@yashashwini2322

try the above mentioned expression

use single assign activity

can you copy and paste this exactly

String.Join(", ", array.Select(Function(item) """" + item + """").ToArray())

@yashashwini2322

Hi @yashashwini2322

You can use below workflow

inputString = “a, b, c, d”

itemsArray = inputString.Split(","c)

outputString = String.Join(“,”, itemsArray.Select(Function(item) “”“” & item & “”“”))

HI @yashashwini2322

This Xaml exactly

Xaml : - Double Quotes.zip (1.8 KB)

output : -

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