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

162
Views
JS: cómo reemplazar   en expresiones regulares para enlaces

Tengo una expresión regular que reemplaza el enlace desde el momento http hasta la aparición de ciertos caracteres en [] , me gustaría agregar   a estos caracteres, es decir, reemplazar la cadena con la aparición de ciertos caracteres o un espacio duro:

"https://test.pl'".replace(/https?:\/\/[^ "'><]+/g," ")

Funciona bien para los caracteres mencionados en [] , no sé cómo agregarlos aquí &nbsp ;

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Puedes usar

 .replace(/https?:\/\/.*?(?:&nbsp;|[ '"><]|$)/g," ")

Vea la demostración de expresiones regulares .

Detalles :

  • https?:\/\/ - http:// o https://
  • .*? - cualquier cero o más caracteres que no sean caracteres de salto de línea tan pocos como sea posible
  • (?:&nbsp;|[ '"><]|$) - uno de los siguientes:
    • &nbsp; - &nbsp; secuencia de caracteres
    • | - o
    • [ "'><] - un espacio, " , ' , > o < char
    • | - o
    • $ - final de la cadena.

demostración de JavaScript:

 const texts = ["https://test.pl&nbsp;test","https://test.pl'test"]; const re = /https?:\/\/.*?(?:&nbsp;|[ '"><]|$)/g; for (const s of texts) { console.log(s, '=>', s.replace(re, " ")); }

about 4 years ago · Santiago Gelvez 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!