I would like to get departing and returning date from the text and change it to date string
Some text are present above
Departure:Tue 4 Jul, 2023
Returning:Thu 10 Aug, 2023
Some text are present below as well.
I would like to get departing and returning date from the text and change it to date string
Some text are present above
Departure:Tue 4 Jul, 2023
Returning:Thu 10 Aug, 2023
Some text are present below as well.
Hi,
Can you share specific expected output?
strDate = System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Departure:).*").Value
OR
strDate = System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Returning:).*").Value
Then
CDate(strDate)
Regards,
Thanks
I am using C# project and i converted your code to c#
System.Text.RegularExpressions.Regex.Match(out_StrMailBody, “(?<=Departure:).*”).Value()
But it throws me an error- non invocable member capture.value cannot be used like a method
Hi,
Can you try to remove ()
at the end of the expression?
Regards,
System.Text.RegularExpressions.Regex.Match(yourString,“(?<=Departure:).*”).Value
When i used above code -I am getting the below result
Tue 4 Jul, 2023Returning:Thu 10 Aug, 2023Some text are present below as well.
I need only -Tue 4 Jul, 2023
Hi,
It seems your original string doesn’t have linebreak after date.
In this case, Can you try the following pattern?
System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Departure:)\w+\s+\d+\s+\w+,\s+\d{4}").Value
Regards,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.