I want help with string manipulations using regex as there can be variations in the input

input -

  1. M.T. DHT LEOPARD - here I need to extract whatever is after word M.T.

2.CP dated 09/11/2019
- here I need to extract 09/11/2019

3.LAYCAN - 09/24/2019 – 09/26/2019

  • here I need to extract the two dates

@Gaurav07

Try this:

Str = “M.T. DHT LEOPARD”

     Str = Str.Replace("M.T. ","")            or
     Str = Str.Split("."c)(2)

Str = “CP dated 09/11/2019”

  Str = Str.Split(" "c)(2)                     or
  System.Text.RegularExpressions.Regex.Match(Str,"\d{2}\/\d{2}\/\d{4}").ToString.Trim

Same way other one also.

3.LAYCAN - 09/24/2019 – 09/26/2019

in this one I need to consider LAYCAN as well as there can be data in string like 09/26/2019 which I don’t need , I just need those two dates which are in same line as the word LAYCAN

@Gaurav07
You need to write two regex to achieve this,

1. resultStr = Regex.Match(inputStr,"(?<=LAYCAN).*").ToString.

2. dateMatches = Regex.Matches(resultStr,"\d{2}/\d{2}/\d{4}").

I am attaching the workflow for your reference.Main.xaml (6.3 KB)

1 Like