Ragala
(Ragala)
June 15, 2024, 9:39pm
1
Hi All,
I have a an input string value as mentioned below
XXXX-XXX-1234
Sachin R Tendulkar
XXXX-XXX-0987
Suresh K Raina
XXXX-XXX-4567
Virender K Sehwag
I want the output value as
XXXX-XXX-1234 Sachin R Tendulkar
XXXX-XXX-0987 Suresh K Raina
XXXX-XXX-4567 Virender K Sehwag
Could you please help me with this.
Thanks,
Ragala.
Parvathy
(PS Parvathy)
June 15, 2024, 9:57pm
2
Hi @Ragala
=> Assign activity
Input = "XXXX-XXX-1234
Sachin R Tendulkar
XXXX-XXX-0987
Suresh K Raina
XXXX-XXX-4567
Virender K Sehwag"
=> Use below Regex Pattern in Find Matching Patterns Activity:
Pattern: "[A-Z].*[\s\S]*?[A-Za-z].*"
Pattern Options: Compiled
Text to Search in: Input
Result: Matches
=> Use For Each loop
For Each currentMatch in Matches
WriteLine -> currentMatch.ToString.ReplaceLineEndings(" ")
End For Each
Hope it helps!!
Ragala
(Ragala)
June 16, 2024, 1:16am
3
Hi @Parvathy
Thanks for your effort. After performing the actions as you said
The Final output value is coming as
XXXX-XXX-4567 Virender K Sehwag
But my final out put should be all three names along with their number
Thanks.
lrtetala
(Lakshman Reddy)
June 16, 2024, 2:09am
4
Hi @Ragala
Can you try the below
String.Join(Environment.NewLine, System.Text.RegularExpressions.Regex.Matches(Input, "(XXXX-XXX-\d{4})\r?\n([^\r\n]+)").Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Groups(1).Value + " " + m.Groups(2).Value))
Regards,
lrtetala
(Lakshman Reddy)
June 16, 2024, 2:11am
5
@Ragala
Another way
System.Text.RegularExpressions.Regex.Replace(Input, "(XXXX-XXX-\d{4})\r?\n([^\r\n]+)", "$1 $2")
Regards,
Parvathy
(PS Parvathy)
June 16, 2024, 3:07am
6
Hi @Ragala
Below syntax should help you.
Input = "XXXX-XXX-1234
Sachin R Tendulkar
XXXX-XXX-0987
Suresh K Raina
XXXX-XXX-4567
Virender K Sehwag"
Output = String.Join(Environment.NewLine, System.Text.RegularExpressions.Regex.Matches(Input, "[A-Z].*[\s\S]*?[A-Za-z].*").Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Value.ReplaceLineEndings(" ")))
Let me know if you have any queries. I will help you.
Regards
Ragala
(Ragala)
June 16, 2024, 10:47pm
7
Thanks @Parvathy it is working
Ragala
(Ragala)
June 16, 2024, 10:47pm
8
Thanks @lrtetala Bro. It is working
Ragala
(Ragala)
June 17, 2024, 1:50am
10
Hi @Parvathy sorry to bother you. But I am pretty much impressed with the expression you gave. Does that expression came instantly from your mind or have you done any R&D for that. If yes can you please send me the source link how to get those expressions. Hope you don’t mind.
Thanks
Parvathy
(PS Parvathy)
June 17, 2024, 2:37am
11
Hi @Ragala
You can follow below videos
VIDEO
The regular expressions are written in below website. It is purely on pur requirement how we want the output.
For Linq you can follow below videos
VIDEO
If perfect, please close the topic by marking my post as solution.
Regards
system
(system)
Closed
June 20, 2024, 2:38am
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.