Xyz_ABC_xyz_xyz_xyz_xyz_xyz_xyz.docx how to get value from in between underscores?

hi Team, i am trying to get the value between the 1st and second _ underscore. could somebody please help here.

Hi,

Can you try the following expression?

yourString.Split("_"c)(1)

Regards,

Hi @Yoichi , THank you its working, but will it work in every case, even if i have many underscores.

Hi,

will it work in every case, even if i have many underscores.

Yes, it will also work if there are many underscores. However if there is no underscore, it throws exception.
If you don’t want to get exception, the following might be better.

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=_)[^_]*(?=_)").Value

Regards,

1 Like

@Yoichi ,

Thank you very much for the help, :smile:

1 Like

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