Hi, I need to extract some data in form of Array from below example:
Input String:
[
“Payroll”,
“Data Entry”,
“Garnishment”
]: 0.999751746654511
Expected Output in Array - Payroll, Data Entry, Garnishment.
Advise me with some ideas
Hi, I need to extract some data in form of Array from below example:
Input String:
[
“Payroll”,
“Data Entry”,
“Garnishment”
]: 0.999751746654511
Expected Output in Array - Payroll, Data Entry, Garnishment.
Advise me with some ideas
use this string manipulation under assign activity
Output = System.Text.RegularExpressions.Regex.Match(inputString, “[(.*?)]”).Groups(1).Value
Convert to array by splitting based on ", "
outputArray = Output.Replace(““”, “”).Replace(“””, “”).Split({", "}, StringSplitOptions.None)
cheers!
Use the below code lines in assign activities.
// Assign inputString with the provided string
inputString = "[“Payroll”," + Environment.NewLine + "“Data Entry”," + Environment.NewLine + "“Garnishment”]: 0.999751746654511"
// Extract the relevant part using regex
arrayPart = System.Text.RegularExpressions.Regex.Match(inputString, "\[([^\]]+)\]").Groups(1).Value
// Clean it up by removing quotes and splitting
cleanedArrayString = arrayPart.Replace("“", "").Replace("”", "").Replace(Environment.NewLine, "")
extractedArray = cleanedArrayString.Split(","c).Select(Function(x) x.Trim()).ToArray()
// Now extractedArray contains: { "Payroll", "Data Entry", "Garnishment" }
I haven’t tried it but do let me know in case of any issue. Generated by LLM
Hi @ashokkarale , With the provided expression, I am able to extract the required data. But for each item, the output is with the double quotes. I just need the string without the quotes.
Output received:
0th Index → “Payroll”
1st Index → “Data Entry”
Expected Output:
0th Index → Payroll
1st Index → Data Entry
Hi @Somanath1, the 1st expression gives me NULL Output.
Use this updated line of code
extractedArray = cleanedArrayString.Split(","c).Select(Function(x) x.Trim().Trim({"“"c, "”"c, """"c})).ToArray()
Try this, use assign activity
arrayVariable = System.Text.RegularExpressions.Regex.Matches(inputString.Replace("'", """"), "(?<=\')[a-zA-Z\s]+(?=\')").
Cast(Of System.Text.RegularExpressions.Match)().
Select(Function(m) m.Value).ToArray()
sample output

Hope this helps!
use this one
inputString = “[“Payroll”, “Data Entry”, “Garnishment”]: 0.999751746654511”
’ Corrected regex pattern to extract text inside square brackets
Output = System.Text.RegularExpressions.Regex.Match(inputString, “[(.*?)]”).Groups(1).Value
’ Remove special characters and split into an array
outputArray = Output.Replace(““”, “”).Replace(“””, “”).Split({", "}, StringSplitOptions.None)
Hi @ashokkarale , I am getting an expression error:
Character Constant must contain exactly one character.
Hi, I was able to solve this with the below string manipulation method:
ListVariable = InputString.Replace(Environment.NewLine,“”).Split(“:“c).ToList
For Each item in ListVariable(0).split(”,“C)
String Variable = (item.Replace(”[”,“”).ToString.Replace(“]”,“”).ToString.Replace(“”“”," ")).Trim
Thanks for all your suggestions.
Happy Automation!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.