Wednesday, 28 February 2018

Regex in Vba excel




Can anyone provide the regex for extracting the data between the 2nd and the 3rd "|"



For example, for the below data



2016 Annual | 1.1 - 12.31 | COH (NP) | #21485



The result should be
COH (NP)



Answer



A regex is overkill for this. Just split on "|" and take the desired component:



Sub test()
Dim S As String
S = "2016 Annual | 1.1 - 12.31 | COH (NP) | #21485"
Debug.Print Split(S, "|")(2) 'prints COH (NP)
End Sub

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...