how to remove substring from string in uipath ?
like i have date Your date is: 22-26th March 21
i get date from regex 26th March 21
i need to remove ‘th’ from dates having ‘th’ substring
and
also i need to use group
(?<=Your date is: \d{0,2}-)(?\d{0,2}\w+\s+\w+\s+\d+)
Datetime.ParseExact("22-26th March 21".split("-"c)(1).Replace("th",string.Empty),"dd MMMM yy",system.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")
@prasath17 so i am getting the date from pdf through regex , output is the type system.text.regularexpresssions.match
while looping through matched items ,
check if the item has th
(item.ToString).Contains(“th”)
then assigning the value to string
Result_date = Datetime.ParseExact(item.ToString.split("-"c)(1).Replace(“th”,String.Empty),“dd MMMM yy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)
getting the error as “Assign: Index was outside the bounds of the array.”
assuming that u had stored the input data in input_date
input_date = “Your date is: 2-26th March 21”
then use the below assign activity
output_date=DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(input_date,“(?<=Your date is: \d{0,2}-).*”).Value.ToString.Replace(“th”,“”),“dd MMMM yy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)
using writeline for displaying output_date, u can see results like u had expected
I need to read emails
like i need to
check the email body if there is
“Your date is: 22-26th March 21”
“Your date is: 15-19 Feb 2021”
“Your date is: 25-31st March 21”
“Your date is: 28-02 Apr 21”
take the latest date and get the date in format "dd/mm/yyy"
so i need to check if the match string has (st|nd|rd|th) else not
can I do this in the above LINQ query ?
so everything will be done in a single line of code
Yes I am getting one date only , as a list in matches so it one element in a list
[dd MMM yyyy] format
can I include if condition in the above LINQ for list if there is no abbreviation ?
like when output is [11 May 2021] or [11 May 21] i need 11/05/2021