Hi team Help me in these Regex

Hi Team,

My datatable output as str=“Assessments\n52\nDue for Reassessment\n3\nIncomplete assessments\n25\nAssessment Past Due\n7\nPending manage services”

but I need output as
First Output output =“Assessments”
Second Output Second output=“52 Due for Reassessment”
Third Output=“3 Incomplete assessments”

like these I need Output can ypu anyone help me on this

@Mada_Sai_Krishna,

Split the string using Split. This will give you array of string.

stringArray = inputString.Split({"\n"}, StringSplitOptions.RemoveEmptyEntries)

You can take out each output from array using it’s index like stringArray(0), stringArray(1) etc

Thanks,
Ashok :slight_smile:

Hi there,

you do not necessarily need regex for this. You can use split by function, eg:

Create an array list of string variable, and use an assign as below:

ArrayString = str.Split(New String() {"\n"}, StringSplitOptions.None)

from here you can use assign activities to get out the text you want, eg:

FirstOutput = ArrayString(0)
SecondOutput = ArrayString(1) + " " + ArrayString(2)
ThirdOutput = ArrayString(3) + " " + ArrayString(4)

Hi @Mada_Sai_Krishna

Check the below thread.

Regards

Hi @Mada_Sai_Krishna ,

Please do avoid posting duplicate topics.

If the previous topic was already engaged and there was some information being passed about the workflow, Project type and restrictions, it would be lost in the newer posts i.e in your case, we would not have know the required expression should be in C# (still not sure) if not for the other post.

Do try to engage in the same topic where it was first collaborated with.

On the regex expression for the Input text, we are not very clear on the output representation, do you want to assign the split outputs to separate variables ? If so would the number of splits be always the same ? In your case it would be 5 Splits (5 variables).

If not the same number of split always, we would recommend to store it in a collection like an Array like it is shown below :

System.Text.RegularExpressions.Regex.Split(strText, @"(?=\\n\d+)").Select(x => x.Replace(@"\n", " ").Trim()).ToArray()

Immediate Panel:
image

Let us know if this does not work for all of your cases.

1 Like