import re print( re.sub(r'(foo)(bar)',r'\g<2>\g<1>','foobar'))
More info here https://www.regular-expressions.info/replacebackref.html
import re print( re.sub(r'(foo)(bar)',r'\g<2>\g<1>','foobar'))
# coding=CP1252 import re text = """ LADY CAPULET Alack the day. She’s dead, she’s dead, she’s dead! CAPULET Ha! Let me see her. Out, alas! She’s cold. Her blood is settled, and her joints are stiff. Life and these lips have long been separated. Death lies on her like an untimely frost Upon the sweetest flower of all the field. Nurse O lamentable day! """
import os import subprocess import glob from pathlib import Path root_dir = r"C:\crystalxml" xslFile = r"C:\Saxon\pretty.xsl" for filename in glob.iglob(root_dir + '/**/*.xml', recursive=True): my_parts = filename.split("\\") justname = my_parts[-1].split('.')[0] my_dir = os.path.dirname(filename) newname = fr'{my_dir}\{justname}.html' cmd = fr'java -cp C:\Saxon\saxon-he-10.1.jar net.sf.saxon.Transform -t -s:"{filename}" -xsl:{xslFile} -o:"{newname}"' subprocess.call(cmd)
Guess a Letter:hint ------ | | | 0 | /|\ | / t y p h u _ e _ Wrong Guesses:lmaio Guess a Letter:s ------ | | | 0 | /|\ | / t y p h u s e s Wrong Guesses:lmaio stay of execution