I have value as below.
xxx_Cost_USD_Normal_D20240722_I_Lot1 ----> I want output 202407
xyyu_Summary_USD_Special_D20241022_4545 —> I want output 202410
xxx_Sum_Money_CES_BBC12_May_2024 L12 —> Output 202405
xxx_Sum_Money_CES_BBC4 April_2024 _L4 —> Output 202404
Please guide me for solve it.
Thank you
AJ_Ask
July 25, 2024, 10:54am
2
Hi @fairymemay
You can use the this pattern for regex
2024\d{2}
Hope this helps
@AJ_Ask if next year 2025 I must edit code?
Can use int 6 character for check it?
AJ_Ask
July 25, 2024, 11:04am
4
202[45]\d{2}
This will work for both 2024 & 2025
mkankatala
(Mahesh Kankatala)
July 25, 2024, 11:09am
5
Hi @fairymemay
You can use the below Expression to get the required output.
- Assign -> InputString = "xxx_Sum_Money_CES_BBC12_May_2024L12"
- Assign -> OutputString = DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(InputString.ToString, "(?<=)\d{6}|[A-Za-z]+_\d{4}").Value.ToString, {"yyyyMM","MMMM_yyyy"}, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None).ToString("yyyyMM")
Check the below workflow for better understanding,
The above expression is work for all the values.
Hope it helps!!
1 Like
@mkankatala error as below.
How to solve it?
Thank you
mkankatala
(Mahesh Kankatala)
July 25, 2024, 11:16am
7
Can you show me what the InputString variable has… @fairymemay
InputString variable has to be in String datatype.
In which activity you are passing this expression.
Okay I can solve it. @mkankatala
Can you recommend this case.
xxx_Cost_USD_Normal_D20240722_I_Lot1 ----> I want output 202407
xyyu_Summary_USD_Special_D20241022_4545 —> I want output 202410
mkankatala
(Mahesh Kankatala)
July 25, 2024, 11:20am
10
Okay @fairymemay
I hope you find the solution for your query, If yes Mark my post Mark as Solution to close the loop.
Happy Automation!!
mkankatala
(Mahesh Kankatala)
July 25, 2024, 11:20am
11
The above expression will work for both… @fairymemay
mkankatala
(Mahesh Kankatala)
July 25, 2024, 11:23am
13
Same expression as I given in the above post,
See the below one,
- Assign -> InputString = "xxx_Cost_USD_Normal_D20240722_I_Lot1"
- Assign -> OutputString = DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(InputString.ToString, "(?<=)\d{6}|[A-Za-z]+_\d{4}").Value.ToString, {"yyyyMM","MMMM_yyyy"}, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None).ToString("yyyyMM")
Hope it helps!!
1 Like
system
(system)
Closed
July 28, 2024, 11:23am
14
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.