how to extract characters pass pipe delimeted string

My input string = ABCD|EFGH.

How do I retrieve values 'EFGH' from the input string past pipe delimeted.
MeinhoonaaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
KorbusConnect With a Mentor Commented:
somthing like this oughta do it (with a few assumptions):

String str ="abcd|efgh";
int a=str.IndexOf("|");
String final_value=str.Substring(a+1);
0
 
John_VidmarCommented:
Assumes you have a string with at least one delimeter:
string str ="abcd|efgh";
String final_value=str.Split('|')[1]

Open in new window

0
 
Michael ReeveCommented:
Another approach might be to use LastIndexOf method which returns the last occurrence of a string or characters within the string.

string str = "ABCD|EFGH";
var stringResult = str.Substring(str.LastIndexOf('|') + 1);

Open in new window

0
All Courses

From novice to tech pro — start learning today.