Hi I’m trying to create a regex for validating date in a string. If the date format is matched in that particular string, I need to store that values from the string to the other variable.
static void ExtractDateFromString(Args _args)
{
str inputString = "Some text 2022-02-27 more text";
str pattern = "(\d{4}-\d{2}-\d{2})";
str extractedDate = System.Text.RegularExpressions.Regex::Match(inputString, pattern).toString();
if (extractedDate)
{
info("Extracted Date: " + extractedDate);
info("Other Variable Value: " + extractedDate);
}
else
{
warning("No date pattern found in the input string");
}
}
I’m getting the output like this…
So I’m not sure what is going on , and help me to resolve this issue…