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

182
Vistas
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 Respuestas
Responde la pregunta

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 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