Commits

Victor Stinner committed 7c2542d

Automated commit message

Comments (0)

Files changed (1)

hachoir-regex.wiki

+**hachoir-regex** is regex manipulation Python library. It's used by [[hachoir-subfile|hachoir-subfile]] for fast pattern matching (find file header).
+
+== Examples ==
+
+=== Regex creation ===
+
+{{{
+#!python
+>>> from hachoir_core.regex import parse, createString
+>>> createString("bike") | createString("motor")
+<RegexOr '(bike|motor)'>
+>>> createString("big ") + createString("bike")
+<RegexString 'big bike'>
+>>> r=parse('(cat|horse)')
+>>> r.minLength(), r.maxLength()
+(3, 5)
+}}}
+
+=== Optimizations  ===
+
+{{{
+#!python
+>>> from hachoir_core.regex import parse, createString
+>>> parse("(ma|mb|mc)")
+<RegexAnd 'm[[a-c]'>
+>>>|createString("moto") | parse("mot.")
+<RegexAnd 'mot.'>
+}}}
+
+=== Pattern matching ===
+
+{{{
+#!python
+from hachoir_core.regex import PatternMatching
+p = PatternMatching()
+p.addString("un", 1)
+p.addString("deux", 2)
+p.addRegex("(trois|three)", 3)
+for start, end, item in p.search("un deux trois"):
+    print "%r at %s: user=%r" % (item, start, item.user)
+}}}
+find
+{{{
+<StringPattern 'un'> at 0: user=1
+<StringPattern 'deux'> at 3: user=2
+<RegexPattern 't(rois|hree)'> at 8: user=3
+}}}
+
+== Download ==
+
+ * **[[Install|Download hachoir-regex]]**
+ * See also [[http://cheeseshop.python.org/pypi/hachoir-regex|hachoir-regex on Cheeseshop]]
+
+== See also ==
+
+ * [[http://search.cpan.org/~dland/Regexp-Assemble-0.28/Assemble.pm|CPAN Regexp::Assemble]] (Perl module)
+ * [[http://search.cpan.org/~dankogai/Regexp-Optimizer-0.15/lib/Regexp/Optimizer.pm|CPAN Regexp::Optimizer]] (Perl moduel)
+ * [[http://kodos.sourceforge.net/|Kodos]]: //The Python Regular Expression Debugger//
+ * [[http://project5.freezope.org/kiki/|Kiki]] (website seems to be down, try [[http://swik.net/Kiki|swik.net]] or [[http://packages.qa.debian.org/k/kiki.html|debian.org]]): //tool for python regular expression testing//
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.