简体   繁体   中英

Python script / Notepad++ - Ignore case

Looking for a way to ignore case on a regex replace with Python script on Notepad++

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 :

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

to 'bbbb'

Python script version is 1.0.8.0

Any ideas ?

Thanks

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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