Capture first or second instance of match

The text looks like this:

I want to spread out the running over the week.{d}2020/01/01{d} {d}2020/02/02{d}

I am using this regex to capture the data within {d} markup.

/{d}.*?{d}/gm

However, this selects each group. How can I select only one (say first) instance of {d} match. That is, how do I only select the first {d}2020/01/01{d}.

And out of curiosity, how would that regex be different if I wanted to select the second match {d}2020/02/02{d}.

Answer

To match only first block just don’t use g flag:

/{d}[d/]+{d}/

To match last block use a greedy .* before it and capture it in group #1:

/.*({d}[d/]+{d})/

To get Nth match of this block:

/^(?:.*?{d}[d/]+{d}){2}.*?({d}[d/]+{d})/

Your match is in group #1.

Or else use /{d}[d/]+{d}/g for match and get Nth element from resulting array.

RegEx Demo