fork download
  1. /* http://es.stackoverflow.com/q/51051/127 */
  2.  
  3. class Ideone
  4. {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. String ruta = "C:\\Archive\\carpeta\\archivo.ej";
  8. System.out.println("Ruta: " + ruta);
  9.  
  10. ruta = ruta.replaceFirst("^C:\\\\Archive(?:\\\\+|$)", "E:\\\\");
  11. System.out.println("Reemplazada: " + ruta);
  12. }
  13. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
Ruta: C:\Archive\carpeta\archivo.ej
Reemplazada: E:\carpeta\archivo.ej