# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"#EXTVDJ:.*?[0-9]+.*?t>(.*?)<.*?e>(.*?)<.*?\n.*?mp3"
test_str = ("#EXTVDJ:<filesize>16027776</filesize><artist>Kyau & Albert, Steve Brian</artist><title>Reverie (DJ Version)</title><songlength>397.340</songlength>\n"
"E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\10932465_Reverie_DJ_Version.mp3\n"
"#EXTVDJ:<filesize>14624215</filesize><artist>Paul van Dyk, KINETICA</artist><title>First Contact (Original Mix)</title><songlength>361.739</songlength>\n"
"E:\\Music\\For Sorting\\July 2020\\13319740_First_Contact_Original_Mix.mp3\n"
"#EXTVDJ:<filesize>16609012</filesize><artist>Solarstone, Meredith Call</artist><title>I Found You (Giuseppe Ottaviani Remix)</title><songlength>410.929</songlength>\n"
"E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\9710365_I_Found_You_Giuseppe_Ottaviani_Remix.mp3\n"
"#EXTVDJ:<filesize>13277361</filesize><artist>Darude, Ashley Wallbridge, Foux</artist><title>Surrender feat. Foux (Extended Mix)</title><songlength>328.918</songlength>\n"
"E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\10161893_Surrender_feat__Foux_Extended_Mix.mp3\n"
"#EXTVDJ:<filesize>21313586</filesize><artist>Ciaran McAuley, Clare Stagg</artist><title>All I Want (Mark Sherry Extended Remix)</title><songlength>526.866</songlength>\n"
"E:\\Music\\For Sorting\\July 2020\\13446725_All_I_Want_Mark_Sherry_Extended_Remix.mp3\n"
"#EXTVDJ:<filesize>15246761</filesize><artist>Cosmic Gate, Denise Rivera</artist><title>Body Of Conflict (Elevven Extended Remix)</title><songlength>377.681</songlength>\n"
"E:\\Music\\For Sorting\\July 2020\\12462485_Body_Of_Conflict_Elevven_Extended_Remix.mp3\n"
"#EXTVDJ:<filesize>17663564</filesize><artist>Philippe El Sisi, Omar Sherif</artist><title>Demolition (Original Mix)</title><songlength>438.857</songlength>\n"
"E:\\Music\\For Sorting\\July 2020\\13498731_Demolition_Original_Mix.mp3\n"
"#EXTVDJ:<filesize>13108166</filesize><artist>Alex Kunnari</artist><title>Sundown (Extended Mix)</title><songlength>323.138</songlength>\n"
"E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\10689952_Sundown_Extended_Mix.mp3\n"
"#EXTVDJ:<filesize>16468045</filesize><artist>Chris Schweizer</artist><title>Don't Be Scared (Extended Mix)</title><songlength>408.696</songlength>\n"
"E:\\Music\\For Sorting\\July 2020\\13609598_Don_t_Be_Scared_Extended_Mix.mp3\n"
"#EXTVDJ:<filesize>15035754</filesize><artist>Dan Stone, Victoriya</artist><title>I Can't Tell (Ferry Tayle Extended Remix)</title><songlength>372.702</songlength>\n"
"E:\\Music\\For Sorting\\July 2020\\13689560_I_Can_t_Tell_Ferry_Tayle_Extended_Remix.mp3\n"
"#EXTVDJ:<filesize>16562928</filesize><artist>Seri, Nifra</artist><title>Edge of Time feat. Seri (Extended Mix)</title><songlength>410.285</songlength>\n"
"E:\\Music\\For Sorting\\From USB Stick\\Music\\2017-19\\9090018_Edge_of_Time_feat__Seri_Extended_Mix.mp3\n"
"#EXTVDJ:<filesize>15886841</filesize><artist>Claus Backslash</artist><title>Absolute Delusion (Extended Mix)</title><songlength>395.294</songlength>\n"
"E:\\Music\\For Sorting\\July 2020\\13741469_Absolute_Delusion_Extended_Mix.mp3\n"
"#EXTVDJ:<filesize>18052845</filesize><artist>Sivan, Graham Bell</artist><title>The Sound Of Letting Go (Tribute To Yotam) (Extended Mix)</title><songlength>448.333</songlength>\n"
"E:\\Music\\For Sorting\\July 2020\\13674262_The_Sound_Of_Letting_Go__Tribute_To_Yotam__Extended_Mix.mp3\n")
subst = "$1 - $2"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html