On 02Jul2019 0707, firstname.lastname@example.org wrote:
Taking swapping a file extension as an example of a particular transformation of interest, it would be achieved with something like s.replace(".htm", ".html", only_end=True).
Please don't use string functions for file system paths, they are not reliable cross-platform.
Use pathlib or (if you need pre-3.4 compatibility) os.path:
p = Path(...) p = p.with_suffix(".html") if p.match("*.htm") else p
p = "..." p0, p1 = os.path.splitext(p) p = (p0 + ".html") if os.path.normcase(p1) ==
os.path.normcase(".htm") else p