Files
codeql/javascript/ql/src/RegExp/UnmatchableDollar.qhelp
2018-08-02 17:53:23 +01:00

37 lines
1.0 KiB
XML

<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
The dollar character <code>$</code> in a regular expression only matches at the end of the input, or
(for multi-line regular expressions) at the end of a line. If it is followed by a pattern
that must match a non-empty sequence of (non-newline) input characters, it cannot possibly match,
rendering the entire regular expression unmatchable.
</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 <code>/\.\(\w+$\)/</code> cannot match any
string, since it contains a dollar assertion followed by an escape sequence that matches a
closing parenthesis.
</p>
<sample src="examples/UnmatchableDollar.js" />
</example>
<references>
<li>Mozilla Developer Network: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">JavaScript Regular Expressions</a>.</li>
</references>
</qhelp>