Regex capture string between second appearance and third

Hello,
I have string like this
xxs_s90_w9wun_5 dds-O4s-sssc-IC
And I need to get substring (preferably used regex) between 2nd _ and 3rd _. In my example it is w9wun.
Thank you for help

Just Split it on _ and then take the third item from the array (index 2).

Split("xxs_s90_w9wun_5 dds-04s-sssc-IC","_")(2)

image

A regex could look like this (we keep in mind that regex is left to right anchored for the base point)
grafik

But we keep in mind that with other options (e.g. split) it can be achieved within a more essential style

Hi @Katerina_Chabova

Input = "xxs_s90_w9wun_5 dds-O4s-sssc-IC"

Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=\w+\d+_).*(?=_)").Value.Trim()

Regards

Hi,

FYI, another approach

System.Text.RegularExpressions.Regex.Matches(yourString,"[^_]+")(2).Value

image

Regards,

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