Hi,
I want extract the last word of first line.
Example:
Example 1:
Abc sd mq
Security guard
Dubai
Example 2:
Xyz ouni
Application engineer
Canada
In both the above example I need to extract last word of first line that is
Output:
Example 1 : mg
Example 2: ouni
Can anyone help me in extracting using regex.
1 Like
Yoichi
(Yoichi)
2
Hi,
How about the following expression?
System.Text.RegularExpressions.Regex.Match(yourString,"(?m)\w+$").Value
Regards,
1 Like
Gokul001
(Gokul Balaji)
3
Hi @yashashwini2322
How about this Regular expression?
System.Text.RegularExpressions.Regex.Match(Yourstring,"\S+\n").ToString.Trim
1 Like
Hi @yashashwini2322 ,
Thanks for reaching out to UiPath Community.
Here is the regex pattern which will give you the desired text.
.*\b(\w+)$
Happy Automation.
Thanks,
@pratik.maskar
1 Like
In this string ,I need ‘ouni’ as a extracted output
It’s not extracting the word
@yashashwini2322
try this:
example 2:
input_string=“Xyz ouni
Application engineer
Canada”
System.Text.RegularExpressions.Regex.Match(input_string,"\S+\n").ToString.Trim
example 1:
input_string= “Abc sd mq
Security guard
Dubai”
System.Text.RegularExpressions.Regex.Match(input_string,"\S+\n").ToString.Trim
@yashashwini2322
You can try this with regex expression
System.Text.RegularExpressions.Regex.Split(System.Text.RegularExpressions.Regex.Split(str_Input,"\n")(0),"\s").Last
output : -
@yashashwini2322
once try witth this below syntax
Split( inputstr.Split(vblf)(0)," ").Last
Input is like
@"
Wasim El ouni
Head risk capital &
Model development
"
I’m not getting the answer
you can try this three ways for your output : -
Note : - str_Input = wassim el Ouni
Head Risk Capital &
Model Development
Split(str_Input.Split({vblf},StringSplitOptions.RemoveEmptyEntries)(0)," ").Last
System.Text.RegularExpressions.Regex.Split(System.Text.RegularExpressions.Regex.Split(str_Input,"\n")(0),"\s").Last
System.Text.RegularExpressions.Regex.Split(str_Input.Split({vblf},StringSplitOptions.RemoveEmptyEntries)(0)," ").Last
@yashashwini2322
Try this xaml
Xaml : - Extract last word of first line.zip (1.6 KB)
i have kept three message boxes based on that you can use any one
@yashashwini2322
Thank you,it worked for me
1 Like
system
(system)
Closed
17
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.