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

303
Views
Linux SED RegEx reemplazar, pero mantener comodines

Si tengo una cadena que contiene esto en alguna parte (Foo podría ser cualquier cosa):

 <tag>Foo</tag>

¿Cómo podría, usando SED y RegEx, reemplazarlo con esto:

 [tag]Foo[/tag]

Mi intento fallido:

 echo "<tag>Foo</tag>" | sed "s/<tag>\(.*\)<\\/tag>/[tag]\1[\\/tag]"
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

A su expresión regular le falta la terminación /

 $ echo "<tag>Foo</tag>" | sed "s/<tag>\(.*\)<\\/tag>/[tag]\1[\\/tag]/" [tag]Foo[/tag]
over 4 years ago · Santiago Trujillo Report

0

Con esto, puede reemplazar todos los tipos de etiquetas y no tiene que ser una etiqueta específica.

 $echo "<tag>Foo</tag>" | sed "s/[^<]*<\([^>]*\)>\([^<]*\)<\([^>]*\)>/[\1]\2[\3]/"

espero que esto ayude.

over 4 years ago · Santiago Trujillo 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!