Hi Team, I need to extract the string using regex
Input string: Jul 19, 2024 11:00 PM
Need Output Separately like:
Jul 19, 2024
11
00
PM
thanks
shaik
Hi Team, I need to extract the string using regex
Input string: Jul 19, 2024 11:00 PM
Need Output Separately like:
Jul 19, 2024
11
00
PM
thanks
shaik
You can use the below regular expressions,
[A-Za-z0-9,\s]+(?=\s+\d+:)|\d+|[A-Z]+

Hope it helps!!
Check the below workflow for better understanding… @shaik.muktharvalli1
Sequence2.xaml (13.4 KB)
Hope it helps!!
StrText="Jul 19, 2024 11:00 PM"
StrDate=System.Text.RegularExpressions.Regex.Match(StrText,"[A-Za-z]+\s*\d{2}\,\s*\d+").Value
StrHour=System.Text.RegularExpressions.Regex.Match(StrText,"\d+(?=\:)").Value
StrMinutes=System.Text.RegularExpressions.Regex.Match(StrText,"(?<=\:)\d+").Value
StrPM=System.Text.RegularExpressions.Regex.Match(StrText,"(?<=\:\d+\s)[A-Z]+").Value
yes sure… @shaik.muktharvalli1
Check the below regular expressions,
- Assign -> Input = "Jul 19, 2024 11:00 PM"
- Assign -> Match1 = System.Text.RegularExpressions.Regex.Match(Input.ToString, "[A-Za-z0-9,\s]+(?=\s+\d+\:)").Value.ToString.Trim
- Assign -> Match2 = System.Text.RegularExpressions.Regex.Match(Input.ToString, "\d+(?=\:\d+)").Value.ToString.Trim
- Assign -> Match3 = System.Text.RegularExpressions.Regex.Match(Input.ToString, "(?<=\d+\:)\d+").Value.ToString.Trim
- Assign -> Match4 = System.Text.RegularExpressions.Regex.Match(Input.ToString, "(?<=\d+\:\d+\s+)[A-Z]+").Value.ToString.Trim
Check the below workflow for better understanding,
Sequence2.xaml (13.4 KB)
Hope it helps!!
If its a date time stamp, can’t we convert this into date and then use Short Date, hh, mm and so on.
Screen:

Code Workflow:
DateSplitter.xaml (7.6 KB)
Expressions:
Convert String to a DateTime Variable using
DateTime.Parse(DateStr)
For printing Date:
DateVar.ToString(“MMM dd, yyyy”)
For Printing Hours:
DateVar.ToString(“hh”)
For Printing Minutes:
DateVar.ToString(“mm”)
For printing Meridian:
DateVar.ToString(“tt”)
Good idea… @adiijaiin
We can get the required strings by using Date Manipulations… @shaik.muktharvalli1
Check the below one,
- Assign -> StrDate = DateTime.ParseExact(Input.ToString, "MMM dd, yyyy hh:mm tt", System.Globalization.CultureInfo.InvariantCulture).ToString("MMM dd, yyyy")
- Assign -> StrHours = DateTime.ParseExact(Input.ToString, "MMM dd yyyy hh:mm tt", System.Globalization.CultureInfo.InvariantCulture).ToString("hh")
- Assign -> StrMinutes = DateTime.ParseExact(Input.ToString, "MMM dd, yyyy hh:mm tt", System.Globalization.CultureInfo.InvariantCulture).tostring("mm")
- Assign -> StrFormat = DateTime.ParseExact(Input.ToString, "MMM dd, yyyy hh:mm tt", System.Globalization.CultureInfo.InvariantCulture).tostring("tt")
You can also use this DateTime Manipulations to get the required result.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.