How to pick date from text data

Hi,

Text data consists of date need to extract date from text data , how to do this. please help.
Input:
APP was removed from A/C N00006 on 07/25/2020
APP was removed from A/C N110AE on 02/05/2020
APP was removed from A/C X103NN on 07/02/2020
Expected output:
07/25/2020
02/05/2020
07/02/2020

Regards,
Lakshmi

HI @lakshmi.mp

How about this expresion

System.Text.RegularExpressions.Regex.Match(YourString,"\d.{2}\d.{2}\d.{3}").Tostring

image

Regards
Gokul

HI @lakshmi.mp

Alternative way

System.Text.RegularExpressions.Regex.Match("APP was removed from A/C X103NN on 07/02/2020","(?<=APP was removed from A\/C.*)\W\d.+").ToString

image

Regards
Gokul

1 Like

@lakshmi.mp
grafik


 strText
 @"APP was removed from A/C N00006 on 07/25/2020
 APP was removed from A/C N110AE on 02/05/2020
 APP was removed from A/C X103NN on 07/02/2020"
 strPattern = "\d{2}\/\d{2}\/\d{4}"
 "\d{2}\/\d{2}\/\d{4}"
 myMatches = System.Text.RegularExpressions.Regex.Matches(strText,strPattern)
 MatchCollection(3) { [07/25/2020], [02/05/2020], [07/02/2020] }
 myMatches.Cast(Of Match).Select(Function (m) m.Value).toArray
 string[3] { "07/25/2020", "02/05/2020", "07/02/2020" }

arrResult | String() - String Array =
myMatches.Cast(Of Match).Select(Function (m) m.Value).toArray

3 Likes

Hi @lakshmi.mp use this regex to fetch only date from hte input text

Regex: “\d{1,2}\S{1}\d{1,2}\S{1}\d{4}”

Regards

Sreejith S S

2 Likes

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