There is a way to eliminate certain parts of a string. example
FECHA DE GENERACIÓN: 26/04/2019 HORA: 4:00 P.M.
I want to erase: GENERATION DATE: _____ TIME: 4:00 P.M.(this time varies)
I just want to stay with the text 04/26/2019, but this text also variate
You can use regex replace to replace everything that isn’t in the date format with an empty string. s the date format in dd/MM/yyyy or MM/dd/yyyy format?
EDIT: Since you’re just pulling out the date only, I wouldn’t even use regex replace. I would just pull out a regex match instead. Put this in an assign activity where YourDate is a string variable, and InputText is a string variable. YourDate = system.Text.RegularExpressions.Regex.Match(InputText,“\d{2}/\d{2}/\d{4}”).ToString
Hi buddy @
This can be done with this assign activity like
in_text = “FECHA DE GENERACIÓN: 26/04/2019 HORA: 4:00 P.M” out_date_value =Split(in_text.Split(“GENERACIÓN:”)(1).ToString.Trim,“HORA” )(0).ToString.Trim
see
this would work for sure
Cheers @askPWC
@AshwinS2 and @Palaniyappan - both of these answers would work in this exact situation but are quite fragile. Substring is ok if it’s in the exact spot every single time. String split works if it will always be preceded by those exact words and spaces, and is always in the same order. Regex will work in all cases
@Palaniyappan - that is the risk for the regex solution. If the pattern of what you’re looking at changes, then you’d need to find a new pattern. As long as it is ## / ## / #### (without spaces in between, where # = any digit) then it would not fail. If the entire pattern is apt to changes, then I agree a different method should be used. In general it is more likely that the order of words would change rather than the actual format of the date though
I still think this is more prone to error based on the information provided. If there were multiple date formats to be pulled out, it’s better to include that in your regex pattern. It’s always a case-by-case situation though and is dictated by the process itself