We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 05313fb commit f1d93c8Copy full SHA for f1d93c8
examples/python-snippets/regex.py
@@ -0,0 +1,19 @@
1
+import re
2
+
3
+strings = [r"<a>this is my string</a>",
4
+ r"<b>this is a different string</b>"]
5
6
+# this is the pattern that we will match -- it has 3 groups
7
+re_test = r"<(\w)>(.*)</(\w)>"
8
9
10
+for s in strings:
11
+ a = re.search(re_test, s)
12
13
+ if not a == None:
14
+ if a.group(1) == a.group(3):
15
+ # we found a match
16
+ print "string in '{}' tags is: {}".format(a.group(1), a.group(2))
17
18
19
0 commit comments