Can anyone help me making it variable?

outputFinal =
System.Text.RegularExpressions.Regex.Match(extractDTString.ToString,“(. ?)-. ?(”+ todDate +“). ?-. ?([A-Z]+).*?(”+ ExecutionHour +“)”).ToString

where
todDate = DateTime.Now.tostring(“yyyyMMdd”)
ExecutionHour =Cint(DateTime.Now.tostring(“hh”))

but it’s giving issue:

image

@anjasing

add .toString after ExecutionHour

like this
System.Text.RegularExpressions.Regex.Match(extractDTString.ToString,"(. ?)-. ?("+ todDate +"). ?-. ?([A-Z]+).*?("+ ExecutionHour.ToString +")").ToString

String.Format("(.*?)-.*?({0}).*?-.*?([A-Z]+).*?({1})", Now.tostring("yyyyMMdd"),DateTime.Now.toString("HH"))

HI,
outputFinal = System.Text.RegularExpressions.Regex.Match(extractDTString.ToString,String.Format(“(.?)-.?({0}).?-.?([A-Z]+).*?({1})”, Now.tostring(“yyyyMMdd”),DateTime.Now.toString(“HH”))).ToString

Isn’t it correct?

can you test it within your immdediate panel?
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

the pattern itself you also can test e.g. https://regex101.com/

we would suggest to use a variable for the pattern e.g. strpattern and use it within the regex.match method. This makes the implementation more easy to read and trace