[英]Python regex to replace everything between a string and a period followed by a parentheses
txt = **(Note:** %Program Files% is the default Program Files folder, usually C:\Program Files in Windows 2000, Server 2003, and XP (32-bit), Vista (32-bit), 7 (32-bit), and 8 (32-bit), or C:\Program Files (x86) in Windows XP (64-bit), Vista (64-bit), 7 (64-bit), and 8 (64-bit) **.)** ***IMPORTANT TEXT*** **(Note:** %Application Data% is the current user's Application Data folder, which is usually C:\Documents and Settings\{user name}\Application Data on Windows 2000, XP, and Server 2003, or C:\Users\{user name}\AppData\Roaming on Windows Vista, 7, and 8.. %Program Files% is the default Program Files folder, usually C:\Program Files in Windows 2000, Server 2003, and XP (32-bit), Vista (32-bit), 7 (32-bit), and 8 (32-bit), or C:\Program Files (x86) in Windows XP (64-bit), Vista (64-bit), 7 (64-bit), and 8 (64-bit)**.)** ***IMPORTANT TEXT*** **(Note:** %Application Data% is the current user's Application Data folder, which is usually C:\Documents and Settings\{user name}\Application Data on Windows 2000, XP, and Server 2003, or C:\Users\{user name}\AppData\Roaming on Windows Vista, 7, and 8 **.)**
我有一个像 txt 这样的文本,我想删除 *(NOTE: * and .)之间的所有内容,只删除(重要文本)。 我已经写了这个正则表达式\(Note:([^)]+\.\))
但它只找到最后一个注释。 另外,我尝试了\(Note:([^)]+.\))
但也考虑了第一个右括号。 我正在使用re.sub(\(Note:([^)]+.\)), '', txt)
知道吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.