Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
How can we remove dots and back slashes along with word using regex

In my react hooks app while iterating the photo field, the src={photo}, it is coming as ..\public\images\photo-1654221497889.png I would like to remove,the word ..\public\ along with dots and back slashes using regex, but this is not working for me. I am expecting to get the resultant as follows images\photo-1654221497889.png

{
searchResults.slice(0, loadRequests).map(({id, photo, name }) => (
                        <div className='row'>
                            <div className="playerRow"> 
                                <label key={id}>
                                    <div className="row">
                                        <div className="checkStyle1">
                                            <input type="checkbox"></input>
                                        </div>
                                        <div className="plyPhoto">
                                            <img src={photo.replace(/[^..\public\]/g,"")}></img>
                                        </div>
                                         <div className="plyName">
                                            <div>{name}</div>
                                        </div>
                                    </div>
                                </label>
                            </div>  
                            
                        </div>  
                   ))}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

For this specific question, why not substring?

Specific regex: "^[.]+\\public\\"

General regex, keep only last two path: "^([^\\]*\\)*(.+\\)" and replace it with the second group: "$2"

If your want to learn regex, this is very concise resource: https://github.com/ziishaned/learn-regex

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda