Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Substring until end of the character

Tags:

c#

.net

How can I substring a character until the end of the text which the length of the string always changes? I need to get everything after the ABC The samples are:

ABC123
ABC13245
ABC123456
ABC1
like image 711
user3314399 Avatar asked Apr 21 '15 23:04

user3314399


People also ask

How do you substring until a character?

Use the substring() method to get the substring before a specific character, e.g. const before = str. substring(0, str. indexOf('_')); . The substring method will return a new string containing the part of the string before the specified character.

How do you find the substring at the end of a string?

To extract a substring that begins at a specified character position and ends before the end of the string, call the Substring(Int32, Int32) method. This method does not modify the value of the current instance. Instead, it returns a new string that begins at the startIndex position in the current string.

How do substring () and substr () differ?

The difference between substring() and substr()The two parameters of substr() are start and length , while for substring() , they are start and end . substr() 's start index will wrap to the end of the string if it is negative, while substring() will clamp it to 0 .

What is substring with example?

A substring is a subset or part of another string, or it is a contiguous sequence of characters within a string. For example, "Substring" is a substring of "Substring in Java."


1 Answers

string search = "ABC"; 
string result = input.Substring(input.IndexOf(search) + search.Length);
like image 98
Greg Ennis Avatar answered Oct 08 '22 19:10

Greg Ennis