Split string on first period where string has multiple periods

if i have an email like this example: aa.chris.dease@example.com ; and i just want to split on the first period and keep the rest as a seperate string (chris.dease@example.com); how could i accomplish that? The first character could be different values as well. For example: “da.”; “sa.”; “aa”; and sometimes only one character before the first period like “a.” .

Regards,
Deaser59

try this

strVar.Split(new[] { '.' }, 2);

here 2 means The maximum number of substrings to return.String.Split Method (System) | Microsoft Learn)
so you will get two strings as output
Try this in the immediate panel for a better understanding

i’m getting this error:

i also changed strVar to my variable and still didn’t work

Hi @deaser59,

value = “aa.chris.dease@example.com

value = value.Substring(value.Split("."c)(0).Count+1)

This format will always work as long as the dot is present.

Regards,
MY

that worked! thank you!

1 Like

OrElse

String.Join(“.”,Str_Value.Split("."c).Skip(1).To array)

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