Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove characters before character "."

Tags:

c#

How effectively remove all character in string that placed before character "."?

Input: Amerika.USA

Output: USA

like image 417
loviji Avatar asked Jun 02 '10 15:06

loviji


People also ask

How do I remove all characters from a string before a specific character?

Remove everything before a character in a string using Regex We need to use the “. *-” as a regex pattern and an empty string as the replacement string. It deleted everything before the character '-' from the string.

How do I extract text before and after a specific character in Excel?

To get text following a specific character, you use a slightly different approach: get the position of the character with either SEARCH or FIND, subtract that number from the total string length returned by the LEN function, and extract that many characters from the end of the string.

How do I delete everything before a character in sheets?

RIGHT+LEN+FIND. There are a few more Google Sheets functions that let you remove the text before a certain character. They are RIGHT, LEN and FIND.


2 Answers

You can use the IndexOf method and the Substring method like so:

string output = input.Substring(input.IndexOf('.') + 1); 

The above doesn't have error handling, so if a period doesn't exist in the input string, it will present problems.

like image 106
casperOne Avatar answered Oct 23 '22 20:10

casperOne


You could try this:

string input = "lala.bla"; output = input.Split('.').Last(); 
like image 41
Christian Avatar answered Oct 23 '22 22:10

Christian