Hello colleagues,
Could you help me with the following issue?
what I want to achieve is to read a text, saved in a variable, from the last line to the first one. I don’t know how to achive it. I saw examples on how to read a text backwards, like this: backwards = “sdrawkcab”.
But I need something more like this:
My name is Jhon,
I am 13 years old,
I am tall,
I have a dog
and make the system read it like:
I have a dog,
I am tall,
I am 13 years old,
My name is Jhon,
Is there a way to achieve this?
Thanks in advance
Andres
Split the text based on myText.Split(Environment.NewLine)
Get the length of the lines
in while loop, use lines length logic to loop through each line and execute the last line first and go backward by using counter logic.
Attached is the xaml file for your reference. Please let me know if it meets your requirement.
Step 1: Save your text as String1. Step 2: Capture each line as an Array of String
Arr_Matches = System.Text.RegularExpressions.Regex.Matches(String1, “.+”).Cast(Of System.Text.RegularExpressions.Match)().Select(Function(a) a.Value).ToArray()
Step 3: Reverse the array’s order
You will need to save this using a new/different Array of String.
Arr_Reversed = arr_Matches.Reverse().ToArray
Step 4: Join Array of String using a new line to separate them.
Join(arr_Reversed, Environment.NewLine)