I need help extracting information from subjectline

Hi,
The subjectline looks like this.
TZL5001_877-16C02099_SEABN_1_201210610

I want to extract everything from the start of the string to the second underscore.

Information about the string.
The characters and digits will change. But the first group (TZL5001) will always be 3 char and 4 digits.

The second group (877-16C02099) will also change. But that doesnt matter. Ill just want to extract everything between the first 2 underscores. and these underscores will always have this position in the string.

So. in short. I want to extract the bolded part of the string.
TZL5001_877-16C02099_SEABN_1_201210610

Any help would be helpful
Milo

grafik
Alternate
grafik

If the underscores are always in the same position, that means the string is always the same length. So just use Left(yourStr,20)

Hi Paul,
Thanks
The number of char and digits in the group between the underscores will change.
is it another way to extract the bolded part TZL5001_877-16C02099 _SEABN_1_201210610?

all the best
milo

Dear ppr

thank you.

Im not that good with regex.

is it another way to extract the bolded part TZL5001_877-16C02099 _SEABN_1_201210610 without using regex?

all the best
milo

Hi,

Can you try the following?

String.Join("_",yourString.Split({"_"c}).Take(2))

Regards,

Dear Yolchi,

Your suggestion String.Join("",yourString.Split({""c}).Take(2))
give me this result: NEL1016_382-18C00769_SEABN. Can you please give me a suggestion how to narrow it down a little bit more to this (NEL1016_382-18C00769_)

And if you would be so kind and give a suggestion on how to extract the first group NEL1016_

Regards
Milo

was splitting without SEABN
grafik

Damn!
i am sorry that i gave you incomplete/wrong info.,But i meant the Subject line not String.
The Subject line is as follows.
NEL1016_382-18C00769_SEABN
extract the bolded part NEL1016_382-18C00769_SEABN
and then i want to extract the first group (NEL1016)

Sorry for any inconvienience
Milo

ill tried to use message.subject.split. But i just cant get it right.

myStr.Split("_“c)(0).ToString + myStr.Split(”_"c)(1).ToString

image

myStr.Split("_"c)(0).ToString