I received a private message from @Desa19 asking for help:
Hello MarqueeCrew,
I thought I should send this directly to, I realised you have been offering some very good assistance to issues relating to Parsing, unfortunately I could not exactly solve my case using all the hints I read from your contributions. Well here is my Problem:
I am having some difficulties using Regex to extract a specific part of a string field within my Data.
I have for example a field with the following string: 99999998_20180501_001_21_11+22_ORDERS
I will like to extract the Year and Month (marked in green) for each single record within that field. The field ist automatically generated and the date changes depending on the date of input of the record (YYYYMMDD), else the format remains the same for all the records. Only exception could be the prefix that could vary between "ORDERS" and "OFFERS"
I will appreciate your assistance.
Thanks
Desa
I'm going to answer via the forum and welcome competing solutions.
Cheers,
Mark
Solved! Go to Solution.
If the string is FIXED and the date component always is in the same position, skip Regex with:
DateTimeParse(Substring([Field1],9,8),"%Y%m%d")
If the beginning of the string is variable in length, Regex is a quick help:
DateTimeParse(REGEX_Replace([Field1], "\d+_(\d{8})_.*", '$1'),"%Y%m%d")
Cheers,
Mark
Thanks MarqueeCrew,
the second option you just proposed is most adapted to my case since there is the possibility that the beginning of the string might vary, this will work just well, I am grateful for that.
Best regards,
Desa