[英]matching html <form> with python regex except the “get” ones
outtext = re.sub(r"(?<!\")<form.*?>", "\g<0> <input > ", intext,re.I|re.M|re.X)
I have this regular expression in which I want to replace all <form >
tags with <form ><input>
tags 我有这个正则表达式,我想用<form ><input>
标记替换所有<form >
<form ><input>
标记
Now the problem is i want to skip the substitution when the form is not a post means has a "method=GET", means I do not want it so match something like <form method="get">
but it should match <form>
or <form isform=1>
现在的问题是,当表单不是帖子时,我想跳过替换,意味着有一个“ method = GET”,这意味着我不想要它,所以要匹配<form method="get">
但它应该匹配<form>
或<form isform=1>
Any suggestions? 有什么建议么?
Try adding a negative lookahead to your current regex: 尝试在当前正则表达式中添加负前瞻:
(?<!\")<form(?![^>]*method=\"get\").*?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.