java - why does a string who clearly contains a piece of other, not result in a found hit using .contains()? -


this program attempts scan text file radio music log, , match songs directory of wav files. files named same convention: artist-title, ie: lukebryan-kickthedustup.wav. swap locations of title , artist using delimiter feature, allows easy comparison music log, formatted same way: title, artist.

now, lets i'm searching term "lovingyoueasyza", loving easy zac brown band... when reaches file in directory assigned string "lovingyoueasyzacbrownband", ignores it, though contains string. you'll see i'm calling:

if(searchme.contains(findme)) 

yet doesn't return hit. will return matches if findme string only contains song title, if part of artist title creeps string, stops working. why!? shorter titles critical able search artist name well, why can't search song title.

i've tried using .trim() no avail. here sample output of when match found:

searching term: "onehellofanamen" comparing to: "onehellofanamendbrantleygilbert" match found! value of findme: onehellofanamen value of searchme: onehellofanamendbrantleygilbert value of y: 49 value of x: 79 

here sample output of failed attempt match:

searching term: "lovingyoueasyza" comparing to: "keepmeinminddzacbrownband" searching term: "lovingyoueasyza" comparing to: "lovingyoueasydzacbrownband" searching term: "lovingyoueasyza" comparing to: "nohurrydzacbrownband" searching term: "lovingyoueasyza" comparing to: "toesdzacbrownband" searching term: "lovingyoueasyza" 

this findme's go method as:

filetoprocess var is: c:\test\06012015.txt slot #0: topofhouridplac slot #1: lovemelikeyoume slot #2: wearetonightbil slot #3: turnitoneliyoun slot #4: lonelytonightbl slot #5: stopset slot #6: alrightdariusru slot #7: lovingyoueasyza slot #8: sundazefloridag slot #9: stopset 

the final output of matchesfound this:

item number: 0 ****top of hour**** item number: 1 d:\tocn\kelseaballerini-lovemelikeyoumeanit.wav item number: 2 null item number: 3 null item number: 4 null item number: 5 ****stop set**** item number: 6 null 

... through 82.

public static string[] regionmatches(string[] directoryarray,             string[] musiclogarray) throws interruptedexception {          string[] matchesfound = new string[musiclogarray.length];         string[] originalfilelist = new string[directoryarray.length];          (int y = 0; y < directoryarray.length; y++) {              originalfilelist[y] = directoryarray[y];              system.out.println("o value: " + originalfilelist[y]);             system.out.println("d value: " + directoryarray[y]);          }          (int q = 0; q < originalfilelist.length; q++) {             originalfilelist[q] = originalfilelist[q].replaceall(".wav", "");             originalfilelist[q] = originalfilelist[q].replaceall("\\\\", "");             originalfilelist[q] = originalfilelist[q].replaceall("[+.^:,]", "");             originalfilelist[q] = originalfilelist[q].replaceall("ctestmusic",                     "");             originalfilelist[q] = originalfilelist[q].replaceall("tocn", "");              originalfilelist[q] = originalfilelist[q].tolowercase();             string[] parts = originalfilelist[q].split("-");             originalfilelist[q] = parts[1] + parts[0];             system.out.println(originalfilelist[q]);         }          (int x = 0; x < musiclogarray.length; x++) {              (int y = 0; y < directoryarray.length; y++) {                  //system.out.println("value of x: " + x);                 //system.out.println("value of y: " + y);                 string searchme = originalfilelist[y];                 string findme = musiclogarray[x];                 int searchmelength = searchme.length();                 int findmelength = findme.length();                 boolean foundit = false;                 updatedisplay("searching term: " + "\"" + findme+"\"");                 updatedisplay("comparing to: " + "\"" + searchme + "\"");                  //for (int = 0; <= (searchmelength - findmelength); i++) {                      if(searchme.contains(findme)){                         updatedisplay("match found!");                         updatedisplay("value of findme: " + findme);                         updatedisplay("value of searchme: " + searchme);                         updatedisplay("value of y: " + y);                         updatedisplay("value of x: " + x);                          matchesfound[x] = directoryarray[y];                         break;  //                  if (searchme.regionmatches(i, findme, 0, findmelength)) { //                      foundit = true; //                      updatedisplay("match found!: " //                              + searchme.substring(i, + findmelength)); // //                      matchesfound[x] = directoryarray[y]; // //                      break;                     } else if (findme.contains("stopset")){                          matchesfound[x] = "****stop set****";                         break;                      } else if (findme.contains("topofho")) {                          matchesfound[x] = "****top of hour****";                         break;                      }                 }                 //if (!foundit) {                 //  updatedisplay("no match found.");                  //}              }          //}         return matchesfound;     } 

it seems me music directory has bunch of unwanted d's in file put pieces together.

searching term: "lovingyoueasyza" comparing to: "lovingyoueasydzacbrownband"

the comparing string not contain search term because after "easy" there "d" ruins search why having errors including artist names.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -