I am trying to write a script that will search through an html file and then replace the form action. So, in this base code:
<html>
<head>
<title>Forms</title>
</head>
<body>
<form action="login.php" method="post">
Username: <input type="text" name="username" value="" />
<br />
Password: <input type="password" name="password" value="" />
<br />
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
I would like the script to search for the form action = "login.php", but only replace login.php, say newlogin.php. The main thing is that the action of the form can vary from file to file, that is, in another html file login.php can be something completely different, so the regular expression should look for the form action = and replace the text after it (possibly using "as delimiters?"
My knowledge of regular expressions is pretty simple, for example, I would know how to replace only login.php:
(re.sub('login.php', 'newlogin.php', line))
but obviously it is not used, as indicated above, if login.php changes from file to file.
!
=)