Test Input
<!DOCTYPE html>
<html>
<head>
<title>This is a title</title>
<head>
<body>
<div>
<p>H/e/l/l/o abcdefgw/o/r/l/d!</p>
</div>
<body>
<html>
Test Output
<!DOCTYPE html>
<html>
<head>
<title>This is a title</title>
</head>
<body>
<div>
<p>H/e/l/l/o abcdefgw/o/r/l/d!</p>
</div>
</body>
</html>
We do not want to replace every single forward slash with backslash
/
.
Some the of backslashes are intended to be backslashes.
We wish only to replace backslash with forward slash
/
if the backslash is inside of a mispelled HTML tag such as
<kbd>
2
Answers
you can use the folloing pattern:
code online
You can use regular expressions
Text input must be a raw string like r"…"
Output: