UiPath Advanced RPA Developer (UiARD) — Question 6
A developer needs to create an automation process that identifies a file with format "Monthly_Report_MMddyyyy.xlsx". The file name is saved to a variable called strinput.
To extract the date from strinput, which string manipulation method should be used?
Answer options
- A. strinput.Substring(strInput.LastIndexOf("_")+1,8)
- B. strinput.Substring(strInput.IndexOf("_")+1,strInput.IndexOf(".")−1)
- C. strinput.Substring(strInput.IndexOf("_")+1.8)
- D. strinput.Substring(strInput.IndexOf("_")+1,strInput.IndexOf("."))
Correct answer: A
Explanation
Option A is correct as it accurately extracts the date by finding the last underscore and taking the next 8 characters, which corresponds to the MMddyyyy format. Option B is incorrect because it does not correctly account for the length of the date substring. Option C has a syntax error with a misplaced decimal point. Option D also fails to specify the correct length for the date substring.