Remove everything before the first dot in string?

Have a look at String.Substring and String.IndexOf methods.

var input = "3042. Item name 3042.";
var output = input.Substring(input.IndexOf(".") + 1).Trim();

Note that it's also safe for inputs not containing the dot.


string str = "3042. Item name 3042.";
str = str.Substring(str.IndexOf('.') + 1);

Use string.Index of to get the position of the first . and then use string.Substring to get rest of the string.


You want to remove everything before a dot inclusive the dot itself:

String str = "3042. Item name 3042.";
String result = str.Substring(str.IndexOf(".") + 1 ).TrimStart();

String.Substring Method (Int32)

(note that i've used TrimStart to remove the empty space left because your question suggests it)

Tags:

C#