Extract date from html string

@supermanPunch

it gave the below output:

td valign=“top”><img src=“/icons/back.gif” alt=“[DIR]”

@som17 My bad, I guess there was an Editing problem :sweat_smile:, Try this : System.Text.RegularExpressions.Regex.Matches(holdline,“\d\d-\w+-\d{4}”)(0).ToString

still the same error…:frowning:

@som17 Can you show us the Screenshot of the workflow where you have used this expression? Also it would be better if you would explain the process what you want to do and what you are currently doing, it will helps us to give the right solution :sweat_smile:


@som17 Is it possible for you to provide that text file?

try this System.Text.RegularExpressions.Regex.Matches(dt,“\d\d-\w{3}-\d{4}”)(0).ToString

1 Like

@som17 Check this workflow :
GetDatesFromHtml.zip (14.0 KB)

1 Like

hey…i can share you the screenshot of XAML…i am using while loop but u have used ForEach loop

@som17 I think you can use For Each Loop as I have implemented then, do the operations you want to do whatever you were performing in the while, the same in For Each, Also I didn’t understand why you have used “holdline is Not Nothing” as the Condition for While loop :sweat_smile:

because there might be the case that there is no data in the string

@som17 You can use an If Condition at the beginning for that :sweat_smile:

i actually used the foreach of matched inside while only and it gave correct output…Thanks for all the help…:slight_smile: :slight_smile:

@som17 But I do really think that whle loop is not needed, but if it is working for your case. It should be fine :sweat_smile:

1 Like

@som17

You can directly get a DateTime or another String. Given my_string your date string…

String
my_string = "03-May-2017 05:43"

As DateTime

DateTime
result = Convert.ToDateTime(my_string)

As String

String
format = "yyyy-MM-dd"

String
result = Convert.ToDateTime(my_string).ToString(format)`

A Regex to get them all

With groups

\b(?<day>\d{2})-(?<month>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(?<year>\d{4}) (?<hours>\d{2}):(?<minutes>\d{2})\b

Without groups

\b\d{2}-(?>Jan|Feb|Mar|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{4} \d{2}:\d{2}\b

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.