Split string with last index of date and time

Hello everyone,

I want to split string with the last index of date and time format.ex format (17-10-2020 - 12:31:56 PM) and want to extract particular text above attachments

My Excepted output is :“The returned product received does not belong to Puma.” for this scenario
My String is =" Thread Type :
Customer Entry

             Name : Case Manager
                
                    Ldap ID : CASE_MANAGER,

Partner : Justin group

        17-10-2020 - 12:31:56 PM

        The returned product are in syn 

Thread Type :
Customer Entry

             Name : Case Manager
                
                    Ldap ID : CASE_MANAGER,

Partner : Sam group

        17-10-2020 - 12:31:56 PM

    
        The returned product  received does not belong to Puma.

            Attachments
                
                    
                        IMG20201016140810.jpg"

Hi @BALASUBRAMANIAN, which is string u need to split ?

Hi @NIVED_NAMBIAR,

Want to split by the last index of date and time example: “17-10-2020 - 12:31:56 PM”

Note: Date and time will be dynamic

Regards,
Bala.S

You could use RegEx.Split(), e.g.

Parts = System.Text.RegularExpressions.RegEx.Split(InputText, "\d{2}-\d{2}-\d{4} - \d{2}:\d{2}:\d{2} (PM|AM)")
LastPart = Parts(Parts.Count-1)

Parts is an array of string and LastPart is a string.

1 Like

Hi @ptrobot,

Working as expected output

1 Like

Good to hear!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.