I finally managed to wrap glib.Regex()
July 5th, 2007 — gianmtAfter a couple of weeks of fighting with GRegex I finally finished the bindings.
Despite the fact that in the python standard library we already have a regular expression module, glib.Regex() is a more powerful way to manage regexp, a simple example is something like:
import glib
def print_uppercase_words(str):
regex = glib.Regex(“[A-Z]+”, 0, 0)
match_info = regex.match_full(str, -1, 0, 0)
while match_info.matches():
word = match_info.fetch(0)
print word
match_info.next()
reg = match_info.get_regex()
print reg.get_pattern()
print_uppercase_words(“SOLO upPerCase LettErs”)
which will produce this output:
gianmt@urano:~$ python regex.py
SOLO
P
C
L
E
[A-Z]+
Luckyly is what I expected to see…. 🙂
Of course I need to test it and especially….write the docs!