forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMissingPartSpecialGroup.qhelp
More file actions
37 lines (30 loc) · 1.26 KB
/
MissingPartSpecialGroup.qhelp
File metadata and controls
37 lines (30 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
One of the problems with using regular expressions is that almost any sequence of characters is a valid pattern.
This means that it is easy to omit a necessary character and still have a valid regular expression.
Omitting a character in a named capturing group is a specific case which can dramatically change the meaning of a regular expression.
</p>
</overview>
<recommendation>
<p>
Examine the regular expression to find and correct any typos.
</p>
</recommendation>
<example>
<p>
In the following example, the regular expression for <code>matcher</code>, <code>r"(P<name>[\w]+)"</code>, is missing a "?" and will
match only strings of letters that start with "P<name>", instead of matching any sequence of letters
and placing the result in a named group.
The fixed version, <code>fixed_matcher</code>, includes the "?" and will work as expected.
</p>
<sample src="MissingPartSpecialGroup.py" />
</example>
<references>
<li>Python Standard Library: <a href="https://docs.python.org/library/re.html">Regular expression operations</a>.</li>
<li>Regular-Expressions.info: <a href="http://www.regular-expressions.info/named.html">Named Capturing Groups</a>.</li>
</references>
</qhelp>