Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

383
Vistas
How to input single backslash for location input in node.js instead of double backslash?

I am building a application where user input a word to be searched in the files and the location of the folder. But I am unble to create a code where user will input the location in single backslash , instead he have to input double backslash in place of single .

const folderAddress=prompt('Enter Folder Address (replace \ with \\)= '); 

const tags=prompt('Enter tags= ');
 let Assets=tags.split(',');
 let allAssets=(Object.values(Assets));
 //console.log('Assets list= '+allAssets);

 const files=getAllFiles(folderAddress);
 let allFiles=Object.values(files);
 //console.log('file list= '+allFiles);

 let ourFile='C:\\Users\\bagde\\Desktop\\JavaScriptPractice\\Demo.html';

 fs.writeFile(ourFile,' ',function(err){}); // this line will removing all thing in demo.html
    let htm=getFileData('C:\\Users\\bagde\\Desktop\\JavaScriptPractice\\index.html');
    writeIntoFile(ourFile,htm);
 
 for(let i=0;i<allAssets.length;i++){
     let count=0;
     let f=0;
     for(let j=0;j<allFiles.length;j++){
         let add=folderAddress+'\\\\'+allFiles[j];
         let data=getFileData(add);
        // console.log('Complete address= '+add);
         let pCount=countOccurences(data,allAssets[i]);
          if(pCount>0){
              f++;
          }  
         count+=pCount;
     }
     console.log(allAssets[i]+" - Found "+count+" occurrence in "+f+" files");
     fs.appendFile(ourFile,'<tr><td>808Ab</td><td>dummy data</td><td>'+allAssets[i]+'</td><td>dummy data</td><td>  Found '+count+' occurrence in '+f+' files </td></tr>',function(err){});
 }

Suppose if I input var input = "F:\JAVA Books\java topics pdf"; it should return : "F:\JAVA Books\java topics pdf"

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can add the backslash yourself, by doing the following.

(Let's say you want to print it)

console.log("\" + userInput);

Like this, the user doesn't have to add both of the backslashes. Or you could even add both of them yourself in the input tag.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda