I have this 2 strings:
String 1:
AV. LOS TALLERES NRO. 4898 URB. EL NARANJAL LIMA - LIMA - INDEPENDENCIA
String 2:
LA JOYA MZA. I LOTE. 13 -B (PLAZA PRINCIPAL DE LA JOYA) AREQUIPA - AREQUIPA - LA JOYA
I want to output only from 1st string:
LIMA - LIMA - INDEPENDENCIA
and from 2nd string:
AREQUIPA - AREQUIPA - LA JOYA
I'm receiving those strings and I have to show only that part. There're always 3 parts and separated with -
but the text changes, for example: what I receive could be one of:
AREQUIPA - AREQUIPA - AREQUIPA
LIMA - LIMA - ATE
PROV. CONST. DEL CALLAO - PROV. CONST. DEL CALLAO - CALLAO
AREQUIPA - CAMANA - CAMANA
How can I split them? I tried counting from the end to the last space after the -
, but I feel there is a better way.