-2

I am trying to extract a part of the string starting from the character '-' . The String looks likes this Aaron,A-5767 I need to get just the 5767, that is extracting part of the string starting from the special character.

I understanding using the below substring function that selects from start of the string to any spl character

sub = str.Substring(0, index)

But how do start from spl the spl character

user4912134
  • 1,003
  • 5
  • 18
  • 47

1 Answers1

1

I'm not sure whether you want an answer using Substring or whether you were just showing something you've tried to produce something similar...

An easy way however would be to use split:

String str = "Aaron,A-5767";
String[] array = str.split("-");
String left = array[0]; //Aaron,A
String right = array[1]; //5767
Reece Kenney
  • 2,734
  • 3
  • 24
  • 57