'Case-insensitve search using PyKeePass
I am using PyKeePass to programatically access a KeePass database. This code:
from pykeepass import PyKeePass
try:
kp = PyKeePass("info.kdbx", password="12345")
except Exception, e:
print "Got exception",e
lstEntry = kp.find_entries_by_notes(".*Chocolate.*",regex=True)
print lstEntry
print lstEntry[0].notes
prints:
[Entry: "Info/Chocolate (None)"]
Chocolate chips are a great invention
However, there is no way that I can get the result if I use "chocolate" instead of "Chocolate". I have tried the "i" modifier:
"/.*chocolate.*/i"
"(.*chocolate.*)i"
...without success. Any suggestions?
Thanks
Solution 1:[1]
From the PyKeePass documentation, the syntax is:
find_entries_by_notes (notes, regex=False, flags=None, tree=None, history=False, first=False)
where
title,username,password,url,notesandpathare strings. These functions have optionalregexboolean andflagsstring arguments, which means to interpret the string as an XSLT style regular expression with flags.
Thus, you need to use the i-flag like this:
find_entries_by_notes(".*chocolate.*", regex=True, "i")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
