-1

I have been trying to extract "Near Gangotri hospital" and "no 125/6 8th Miles Bus Stop" but i was not able to extract it can any one please help me to extract the string

I need to extract 3 rd string which is after 2 nd Pipe(|) operator.

9649|14:30|Near Gangotri hospital |Opp Central Bank (Test)|9880955077|B T M Layout ~ 8937|14:34|no 125/6 8th Miles Bus Stop|Near 8th Mile Signal|080 65468012222|8th Mile
  • 1
    have you tried the substring method? like string.substring(11,32); See if that gives you the Near Gangotri hospital. Might have to play with the positions. – Adam Gardner Feb 15 '17 at 17:21

1 Answers1

2

You can use String.split(String regex) to split your text and later choose parts you wanted.

String text = "9649|14:30|Near Gangotri hospital |Opp Central Bank (Test)|9880955077|B T M Layout ~ 8937|14:34|no 125/6 8th Miles Bus Stop|Near 8th Mile Signal|080 65468012222|8th Mile";
String parts[] = text.split("|");
String part3 = parts[2]; //Near Gangotri hospital 
u32i64
  • 2,384
  • 3
  • 22
  • 36
YMY
  • 678
  • 9
  • 17