trim the whitespace in the poly-redos examples

This commit is contained in:
erik-krogh
2023-05-15 14:45:57 +02:00
parent d989359656
commit 83ca1495e0
4 changed files with 27 additions and 43 deletions

View File

@@ -15,8 +15,7 @@
</p>
<sample language="python">
re.sub(r"^\s+|\s+$", "", text) # BAD
</sample>
re.sub(r"^\s+|\s+$", "", text) # BAD</sample>
<p>
@@ -71,8 +70,7 @@
</p>
<sample language="python">
^0\.\d+E?\d+$ # BAD
</sample>
^0\.\d+E?\d+$ # BAD</sample>
<p>
@@ -113,8 +111,7 @@
</p>
<sample language="python">
match = re.search(r'^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$', str)
</sample>
match = re.search(r'^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$', str) </sample>
<p>
It's not immediately obvious how to rewrite this regular expression
@@ -124,11 +121,10 @@
</p>
<sample language="python">
if len(str) &gt; 1000:
raise ValueError("Input too long")
if len(str) &gt; 1000:
raise ValueError("Input too long")
match = re.search(r'^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$', str)
</sample>
match = re.search(r'^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$', str) </sample>
</example>
<include src="ReDoSReferences.inc.qhelp"/>