salve,
ecco il mio problema:
ho due stringhe (che rappresentano due indirizzi). esiste un algoritmo collaudato per il confronto delle due, cioè se la prima stringa è contenuta nella seconda ??
faccio un esempio:
a: Via Roma Milano 20000
b: Via Roma Milano 20000 IT
come si può notare la stringa a è contenuta in b ma se
a: Via Rom Milano 20000
b: Via Roma Milano 20000 IT
la stringa a NON è contenuta in b.
In pratica vorrei realizzare un sistema che controlla che ogni parola di a è contenuta in b. Importante è che non deve tenere conto della posizione.
Vi faccio vedere quello che ho realizzato io:
Grazie a tutti.Codice PHP:
String[] awords = a.split(" ");
String[] bwords = b.split(" ");
// perform the comparison
for (int i=2; i<awords.length; i++) {
awords[i] = d.getCityIT(awords[i]);
}
Boolean reply = false;
for (int i=0; i<awords.length && !reply; i++) {
reply = true;
for (int j=0; j<bwords.length && reply; j++) {
if (!awords[i].equals(bwords[j])){
reply = true;
}else
reply = false;
}
}
return (reply);
}
ciao
mauro