Question


Veteran Careers First
US
Last activity: 15 Jul 2018 3:36 EDT
substring/function to parse date
Looking for substring/function to parse date from file name.
I need the date in between the letter y and .xml
I only need the date, regardless of date format.
File Name examples:
- ABCtesty12018.xml####123456789
- ABCtesty012018.xml####123456789
- ABCtesty0012018.xml####12345678912
- ABCDtesty12018.xml####123456
- ABCDtesty012018.xml####12345678913
- ABCDtesty0012018.xml####12345678
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution


Toyota Financial Services
AU
To get the date as per the examples you provided. I understand below two functions will suffice your requirement.
indexof
substring
Something like below.
@substring(param.fileName, @indexOf(param.fileName, "ABCtesty"), @indexOf(param.fileName, ".xml"))
Thanks
Sandeep P V
-
Harmen Denekamp Hector Melara


Veteran Careers First
US
Awesome!
Lifesaver...
Thanks!


Veteran Careers First
US
How would this look if I wanted to get everything before the letter t


Pegasystems Inc.
IN
Hi,
You can also use below function for your requirement.
whatComesBeforeFirst(@String.whatComesAfterFirst("param.fileName",'y'),'.')
Regards,
Vinay Reddy :)


LTI Mindtree
IN
Thank you Vinay
We can use this function


Pegasystems Inc.
IN
Yeah Chaithanya


Veteran Careers First
US
How would this look if I wanted to get everything before the letter t


Pegasystems Inc.
IN
Hi,
You have 2 t's in your string so you if you want everything before first t you can use "1st" function and if you want everything before last t you can use "2nd" function
ABC(t)es(t)y12018.xml####12345678
1.whatComesBeforeFirst(param.fileName,'t') -->ABC
2.whatComesBeforeLast(param.fileName,'t') -->ABCtes
Regards,
Vinay Reddy :)


LTI Mindtree
IN
Hi @HenryA80
Could you confirm your requirement, because I tried both the solutions (Vinay's and Sandeep's) in Pega 7.3.1.
Here is my observation, Vinay's soution is giving exact value (Date in between "y" and ".xml") what you want in your requirement and Sandeep's solution is giving exact file name excluding ".xml". Please find attachments.
If Sandeep's solution working as expected, then could you share how did you get the result.
Thanks


Veteran Careers First
US
Chaitanya,
They both worked!
I used in activity Pega 7.2.2
This was my final solution:
@substring(Param.FileName,@indexOf(Param.FileName,"y")+1,@indexOf(Param.FileName,"."))
I get the Date in between "y" and "."
I have both xml and csv, so instead of ".xml" I just used "."
Let me know if you have any other questions.


LTI Mindtree
IN
Okay, then can you mark Vinay's post also "Correct Answer" so that it is helpful to other people and they can chose any one solution.
Thanks