[gedit-plugins] Improve documentation of regex replace in commander
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] Improve documentation of regex replace in commander
- Date: Sat, 27 Aug 2011 08:36:45 +0000 (UTC)
commit b8fc3515558e8a59d09fb364e679a51308f7c653
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Sat Aug 27 10:34:30 2011 +0200
Improve documentation of regex replace in commander
plugins/commander/modules/find/regex.py | 48 ++++++++++++++++++++++++++++--
1 files changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/plugins/commander/modules/find/regex.py b/plugins/commander/modules/find/regex.py
index dfa5ce1..c200a3d 100644
--- a/plugins/commander/modules/find/regex.py
+++ b/plugins/commander/modules/find/regex.py
@@ -176,28 +176,68 @@ expression syntax is that of python regular expressions. Matching dicards case."
def replace(entry, findre, replstr=None):
"""Find/replace regex in document: find.replace <find> [<replace>]
-Quickly find and replace phrases in the document using regular expressions"""
+Quickly find and replace phrases in the document using regular expressions.
+The <replace> may contain backreferences to groups in the regular
+expression using $0, $1, etc. In addition, a set of simple transformations
+on these backreferences can be performed using instead the syntax ${n:t1[,t2,...]} where
+<n> is the backreference number and <t1>, <t2> are transformations:
+
+u: upper case first character
+U: upper case match
+l: lower case first character
+L: lower case match
+t: title case match"""
fd = RegexFinder(entry)
yield fd.replace(findre, False, replstr)
def replace_i(entry, findre, replstr=None):
"""Find/replace regex in document (case insensitive): find.replace-i <find> [<replace>]
-Quickly find and replace phrases in the document using regular expressions"""
+Quickly find and replace phrases in the document using regular expression.
+The <replace> may contain backreferences to groups in the regular
+expression using $0, $1, etc. In addition, a set of simple transformations
+on these backreferences can be performed using instead the syntax ${n:t1[,t2,...]} where
+<n> is the backreference number and <t1>, <t2> are transformations:
+
+u: upper case first character
+U: upper case match
+l: lower case first character
+L: lower case match
+t: title case matchs"""
fd = RegexFinder(entry, re.IGNORECASE)
yield fd.replace(findre, False, replstr)
def replace_all(entry, findre, replstr=None):
"""Find/replace all regex in document: find.regex.replace-all <find> [<replace>]
-Quickly find and replace all phrases in the document using regular expressions"""
+Quickly find and replace all phrases in the document using regular expressions.
+The <replace> may contain backreferences to groups in the regular
+expression using $0, $1, etc. In addition, a set of simple transformations
+on these backreferences can be performed using instead the syntax ${n:t1[,t2,...]} where
+<n> is the backreference number and <t1>, <t2> are transformations:
+
+u: upper case first character
+U: upper case match
+l: lower case first character
+L: lower case match
+t: title case match"""
fd = RegexFinder(entry, 0)
yield fd.replace(findre, True, replstr)
def replace_all_i(entry, findre, replstr=None):
"""Find/replace all regex in document: find.regex.replace-all-i <find> [<replace>]
-Quickly find and replace all phrases in the document using regular expressions"""
+Quickly find and replace all phrases in the document using regular expressions.
+The <replace> may contain backreferences to groups in the regular
+expression using $0, $1, etc. In addition, a set of simple transformations
+on these backreferences can be performed using instead the syntax ${n:t1[,t2,...]} where
+<n> is the backreference number and <t1>, <t2> are transformations:
+
+u: upper case first character
+U: upper case match
+l: lower case first character
+L: lower case match
+t: title case match"""
fd = RegexFinder(entry, re.IGNORECASE)
yield fd.replace(findre, True, replstr)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]