Get value from the string

Hi Team,
Currently, I have a string that has the description of the product, here where I need to get only the start and end date of the offer.
Example input string value “Poco M4 Pro 5g(cool Blue, 64gb) 4gb ram 1Tb 6.6inch 50mp + 8mp offers Start date: 16/04/2022 End date: 20/04/2022.”

output : start date :16/04/2022
end date : 20.04.2022
Thanks in advance.

Hi @Majunu09 ,

You could try using the below Regex Expression :

(?<=Start date:\s*)\d{2}\/\d{2}\/\d{4}

To get the Value the Expression to be used :

System.Text.RegularExpressions.Regex.Match(textData,"(?<=Start date:\s*)\d{2}\/\d{2}\/\d{4}",RegexOptions.IgnoreCase).Value.ToString.Trim

where textData is your Input String

The Same Method applies for Extracting End Date :

System.Text.RegularExpressions.Regex.Match(textData,"(?<=End date:\s*)\d{2}\/\d{2}\/\d{4}",RegexOptions.IgnoreCase).Value.ToString.Trim

Let us know if it doesn’t work

Hi @supermanPunch , Thank you for the replay, I am getting out as this System.Linq.Enumerable+d__97`1[System.Text.RegularExpressions.Match]., here I used "matches activity.

Hi @Majunu09
Use Matches activity and put this expression–
(?=Start date).*\d{4}
You will get the start date and end date required data

End date in output you have mentioned like this end date : 20.04.2022
If you want “.” instead of “/” just use (?<=End date:.).*\d{4} to get end date data and replace the output string’s “/” with “.”

@Majunu09 , Do you have many dates that need to be Extracted ? If there aren’t many dates for One Input, we wouldn’t require to use the Matches Activity.

If it is Required, we can Loop through the MatchCollection Output in the below way and access the Matched values :

Let us know what is the Implementation you require and Why

@supermanPunch , Getting this error “Error ERROR Validation Error Compiler error(s) encountered processing expression “System.Text.RegularExpressions.Regex.Match( item,”(?<=End date:\s*)\d{2}/\d{2}/\d{4}”,RegexOptions.IgnoreCase).Value.ToString.Trim".
Value of type ‘System.Text.RegularExpressions.Match’ cannot be converted to ‘String’. Main.xaml"

@Shubham_Dutta , Getting same error System.Linq.Enumerable+d__97`1[System.Text.RegularExpressions.Match]., here I used " matches activity .

@Majunu09 , Are you using this inside the For Loop ?

@Majunu09 are you trying to display it in message box? then you are getting this error?

See from matches we get a collection

“Assign” it to a String Variable like this : yourVariable=collectionName(0).ToString
“(0)” to call the first result

Yes. @supermanPunch

or else how to achieve it. @supermanPunch

It display single character if I use index value like (0) = gives “p”. @Shubham_Dutta

@Majunu09 You would not require to use Matches Activity at all. You could try directly the Expression mentioned above :

1 Like

Think we are nearing, “)” expected… @supermanPunch

@Majunu09 Please do provide the Exact Error that is being faced.

If you could provide us with Screenshots, it would be better.

However, Please do Check the Post already having the Expression to use :

Why do you use lookbehind “(?<=” instead of simply using Start date:\s*?
_Test1.xaml (5.5 KB)

@Majunu09 , Could you provide you xaml file ?

Main.xaml (9.7 KB)