EmployeeID:E102 ManagerID:E088 From Date:25/01/2021 To Date: 20/02/2021
I want to split this text like this
EmployeeID:E102
ManagerID:E088
From Date:25/01/2021
To Date: 20/02/2021
And email this text
please help me regarding this…
EmployeeID:E102 ManagerID:E088 From Date:25/01/2021 To Date: 20/02/2021
I want to split this text like this
EmployeeID:E102
ManagerID:E088
From Date:25/01/2021
To Date: 20/02/2021
And email this text
please help me regarding this…
There are multiple ways to handle this format. Please see always your string with the same format and sequence. If not you need to split this string in a different way.
Let me give you algorithm.
strMainValue = “EmployeeID:E102 ManagerID:E088 From Date:25/01/2021 To Date: 20/02/2021”
If (InStr(strMainValue, “EmployeeID”)<>0) Then
strEmpID1 = Split(strMainValue, “EmployeeID”)
’ strEmpID1(0)=“:E102 ManagerID:E088 From Date:25/01/2021 To Date: 20/02/2021”
strEmpID = Split(strEmpID1(0), “ManagerID”)
’ strEmpID(0)=“:E102”
End If
This is how you need to for each ManagerID, From Date, To Date. Because these are consistent always.
Hope my inputs are useful.
You can try to do it using regular expression.
Follow the example.
Variabel
texto = "EmployeeID:E102 ManagerID:E088 From Date:25/01/2021 To Date: 20/02/2021"
Regular Expression
System.Text.RegularExpressions.Regex.Match(texto,"(?<=EmployeeID:)\w+")
System.Text.RegularExpressions.Regex.Match(texto,"(?<=ManagerID:)\w+")
System.Text.RegularExpressions.Regex.Match(texto,"(?<=From Date:)\w+\/\w+\/\w+")
System.Text.RegularExpressions.Regex.Match(texto,"(?<=To Date: )\w+\/\w+\/\w+")
If you just want to add line breaks, you can also use Regex.Replace().
System.Text.RegularExpressions.Regex.Replace(inputText, "(?<=: *[^\s]+) ", Environment.NewLine)