Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex to edit text

Regex does my head in, I’m looking for an expression to take a list of songs and re-format them. I’ve discovered \t to find the tabs, but unable to make any progress on the rest.


From: (with tabs in the middle of number and after artist)

  1. Garth Brooks Friends In Low Places
  2. Backstreet Boys Everybody (Backstreet’s Back)
  3. Spice Girls Wannabe

To:

Garth Brooks – Friends In Low Places

Backstreet Boys – Everybody (Backstreet’s Back)

Spice Girls – Wannabe

Thanks in advance!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You may try the following find and replace in regex mode:

Find:    ^\d+\t(.*?)\t(.*)$
Replace: $1 - $2

Demo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading