Maki92
Maki92

Reputation: 441

Get 2nd occurence of between a pattern

given

System Volume Information|28-May-15 3:16:25 AM|06-Aug-15 9:25:59 AM|5|

I need to get 2nd date of between | | occurrence which is |06-Aug-15 9:25:59 AM| . I am able to get the first and the last |5| with the regex below:

(?<=\|)(.*?)(?=\|) //First Date
(?<=\|)(.?)(?=\|) //Last occurrence|5|

Regex: https://regex101.com/r/aB1sC2/2

Upvotes: 2

Views: 24

Answers (1)

anubhava
anubhava

Reputation: 785128

You can use this regex:

(?:[^|]+\|){2}([^|]+)

And grab captured group #1

Updated RegEx Demo

Upvotes: 2

Related Questions