Extract date from html string

Hi All,

Please help in extracting date from the below string:

03-May-2017 05:43

@som17 If the date is always in the same format, then you can try this :
System.Text.RegularExpressions.Regex.Matches(“03-May-2017 05:43”,"\d\d-\w±\d{4}")(0).ToString

1 Like

the dats can vary…but the format of string will be the same

@som17 Try using the above Expression for all inputs that you have and check if it works

for fileName i am extracting it like this…
when filename in the HTML string is :

3may17.zip
holdline.Substring(holdline.indexof(“href=”)+6,holdline.indexof(""">",holdline.indexof(“href=”)+6)-(holdline.indexof(“href=”)+6))

Can it be dynamic for date as well?

@som17 Can you explain what are you trying to extract from the html ? :sweat_smile:, If you can provide the html String in a Text and tell us what needs to be extracted?

td align=“right”>21-May-2019 12:03 </td

@supermanPunch

@Anthony_Humphries can u please support in this.

@som17 I guess you can use the same Expression, it does extract the date from it.

no…it doesn’t

@som17 What did it return error? Or Null ?

I assigned fileDate=holdline.Substring(holdline.indexof(“align=”)+2,holdline.indexof(""">",holdline.indexof(“align=”)+2)-(holdline.indexof(“align=”)+2))
where holdLine is a string
but BOT is giving output as : ign="top
extracting top froom the string part:
td align=“right”>21-Aug-2019 15:09 td align=“right”>109K

 
td valign=“top”>

@som17 Have you used the expression which I have provided? :sweat_smile:

i cant use that as it will hardcode the string…i have to keep it dynamic

@som17 You can make it dynamic :sweat_smile:

can you please share the kind of expression u r suggesting?

@som17 Considering you have the td tag in the holdline variable, you can try this :
System.Text.RegularExpressions.Regex.Matches(holdline,"\d\d-\w±\d{4}")(0).ToString

it gave error:
Assign: Specified argument was out of the range of valid values.
Parameter name: i

i used it like fileDate= System.Text.RegularExpressions.Regex.Matches(holdline,"\d\d-\w±\d{4}")(0).ToString

You can extract text using substring as below

strText.Substring(strText.IndexOf(">")+1,strText.IndexOf("</")-strText.IndexOf(">")-1).Trim

1 Like