Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
Esta expresión regular se rompe en safari pero funciona en Google Chrome, ¿cómo hago para que funcione en ambos?

Tengo una expresión regular:

 var regex = /(layout)(^|\s*)((?<!=)=(?!=))(^|\s*)/;

Esto funciona en Google Chrome pero no en Safari ni en Internet Explorer. En Safari, el error es:

"Invalid regular expression: invalid group specifier name"

¿Cómo puedo arreglar esto, por favor?

ACTUALIZAR Tengo una entrada xml en la que ejecuto algunas comprobaciones antes de dársela al analizador xml. Una de las comprobaciones es que uso el análisis de cadenas para extraer el nombre del diseño en los nombres de los archivos incluidos.

Intento identificar espacios en blanco en el atributo 'diseño' y limpiarlo, por ejemplo

 <Container width="match_parent" height="wrap_content"> <include width="20px" height="30px" layout = "subcontent.xml" /> </Container>

sería cambiado a

 <Container width="match_parent" height="wrap_content"> <include width="20px" height="30px" layout="subcontent.xml" /> </Container>

Hago esto usando un String.replace, luego extraigo el nombre del archivo incluido y lo cargo desde el almacenamiento y lo pongo en cola para analizarlo también.

Entonces piensa:

 let check = 'layout='; //change layout[space....]=[space.....] to layout= let regex = /(layout)(^|\s*)((?<!=)=(?!=))(^|\s*)/; xml = xml.replace(regex, check);

Espero que sea más claro ahora.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Usar

 let check = 'layout='; let xml = "change layout = "; let regex = /layout\s*=(?!=)\s*/g; xml = xml.replace(regex, check); console.log(xml)

Ver prueba de expresiones regulares .

EXPLICACIÓN

 "layout" - matches the characters layout literally (case sensitive) "\s*" matches any whitespace character between zero and unlimited times, as many times as possible, giving back as needed (greedy) "=" - matches the character = with index 6110 (3D16 or 758) literally - Negative Lookahead "(?!=)": Assert that the Regex below does not match "=" - matches the character = with index 6110 (3D16 or 758) literally "\s*" - matches any whitespace character between zero and unlimited times, as many times as possible, giving back as needed (greedy)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!