i have paragraph and inside that i have more than 5 to 6 lines and inside that there will be many 6 digit numbers and i want to get last number of 6 digit number
@sathish_Kumar6
give me some examples
Here’s how you can implement it in UiPath:
- Use the Assign activity to assign your paragraph to a string variable. Let’s call it
inputText
. - Add the Matches activity to your workflow.
- Input:
inputText
(your paragraph) - Pattern:
\d{6}(?=\D|$)
(the regular expression pattern) - Result: Create a new variable of type
MatchCollection
. Let’s call itmatches
.
- Use an If activity to check if
matches.Count > 0
(to ensure that there is at least one match). - Inside the If activity, use the Assign activity to assign the last six-digit number to a string variable. Let’s call it
lastNumber
.
- Variable:
lastNumber
- Value:
matches(matches.Count - 1).Groups(1).Value
The variable lastNumber
will contain the last six-digit number found in the paragraph.
Hi,
How about the following?
System.Text.RegularExpressions.Regex.Match(yourString,"\d{6}",System.Text.RegularExpressions.RegexOptions.RightToLeft)
it might be better the following if there are 7 or more digits number.
System.Text.RegularExpressions.Regex.Match(yourString,"\b\d{6}\b",System.Text.RegularExpressions.RegexOptions.RightToLeft)
Regards,
Hello…
System.text.RegularExpressions.Regex.Match(“YourString”,“\d{6}(?=$)”).Value
I hope this will help you or else put the input String I will try.
Thank you.
@sathish_Kumar6
Results
hi @Yoichi do i need to change variable type or please look into this error?
Hi,
Sorry, it’s my mistake. Can you try to add .Value as the following?
System.Text.RegularExpressions.Regex.Match(yourString,"\d{6}",System.Text.RegularExpressions.RegexOptions.RightToLeft).Value
Regards,
Thanks a lot…it worked
im getting empty output for this
Thank you so much for the effor reply @raja.arslankhan
Thanks for the efforts
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.