简体   繁体   English

Python脚本/ Notepad ++-忽略大小写

[英]Python script / Notepad++ - Ignore case

Looking for a way to ignore case on a regex replace with Python script on Notepad++ 寻找一种忽略记事本上的Python脚本的正则表达式替换大小写的方法

Tried the following but it doesn't work. 尝试了以下方法,但不起作用。

editor.rereplace(r'aaaa', r'bbbb', re.IGNORECASE)

=> So the replacement should replace any mix of four letters length 'aA' such as : =>因此,替换项应替换长度为“ aA”的四个字母的任意组合,例如:

'AAAA', 'aaAA', 'aAaa' etc... 'AAAA','aaAA','aAaa'等...

to 'bbbb' 到“ bbbb”

Python script version is 1.0.8.0 Python脚本版本为1.0.8.0

Any ideas ? 有任何想法吗 ?

Thanks 谢谢

UPDATE UPDATE

import re
your_editor_text_string = 'I have an OLD_tEXt for this Old_tEXt'
to_be_replaced = re.compile(re.escape('old_text'), re.IGNORECASE)
new_text = to_be_replaced.sub('NEW_TEXT', your_editor_text_string)
print(new_text)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM