Search code examples
androidtesseracttess4j

How to remove hyphens and white space in between of the string?


Using Tess4J jars I got a set of string containing white spaces and hyphens.

V O D) >3 IIIIIII v .. 18:05Desks ¢ 3HOME FIND DESK FIND COLLEAGUE
  BOOKINGS0, SelfiMGiKIOSK708O4il27197097102,
  LOGSM’KIOSK’O8O47127197107682Monday, May 29 2017 Check-in Successful.
  You have successfully checked in to Desk 5555in 

 - Self-MG-KIOSK—0804-12—19-09—102

 on 0 at 

 - Loc-SM-KlOSK—0804-12-19-10-682

I am not able to verify the string as it gets hyphens and whites spaces in Loc-SM-KlOSK—0804-12-19-10-682 & Self-MG-KIOSK—0804-12—19-09—102.


Solution

  • On the 2nd step of previous answer, Try substituting this

    // REMOVE HYPHENS
    String output = input.replaceAll("-","");
    
    // REMOVE WHITESPACES
    output = output.replaceAll(" ","");
    
    // REMOVE ANOTHER STUFFS
    output = output.replaceAll("—","");
    
    // PRINT RESULTS
    Toast.makeText(getApplicationContext(), output, Toast.LENGTH_LONG).show();