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

388
Views
Javascript reemplaza un grupo de captura a mayúsculas (no un duplicado)

Soy consciente de Reemplazar un grupo de captura Regex con mayúsculas en Javascript

Eso es para reemplazar todo el partido y no un () partido.

Aquí está mi problema:

 var text = '<span style="font-variant: small-caps" class="small-caps">Lord</span>' text = text.replaceAll(/<span style="font-variant.*?>(.*)<\/span>/g, function (v) { return v.toUpperCase(); }); console.log(text);

Esto devuelve la etiqueta completa en mayúsculas y no el texto real en (.*).

Solo quiero reemplazar la etiqueta de intervalo con solo las mayúsculas del texto interno. También hay más de una etiqueta de intervalo en la variable de texto real.

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

0

Los grupos de captura se pasan como argumentos adicionales a la función de devolución de llamada. Así que usa el argumento con la captura.

 var text = '<span style="font-variant: small-caps" class="small-caps">Lord</span>' text = text.replaceAll(/<span style="font-variant.*?>(.*)<\/span>/g, (match, g1) => g1.toUpperCase()); console.log(text);

about 4 years ago · Juan Pablo Isaza Report

0

También puede usar />(.*)<\/span>/g

 var text = '<span style="font-variant: small-caps" class="small-caps">Lord</span>'; text = text.replaceAll(/>(.*)<\/span>/g, function(_, group) { return `>${group.toUpperCase()}</span>`; }); console.log(text);

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!