diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-01-06 23:29:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-06 23:29:07 -0500 |
commit | 2a474dc8f13a3a4558136215a7a1706ba13ba732 (patch) | |
tree | dff878d78b4b87bca09e5ce1ab4ebc2e5e3940ec /cmd2.py | |
parent | 5f976639ee947a83dadf888e1307401980d01434 (diff) | |
parent | e8481e18a64a4b4500e6bade7c2602bb0739f9cc (diff) | |
download | cmd2-git-2a474dc8f13a3a4558136215a7a1706ba13ba732.tar.gz |
Merge pull request #245 from python-cmd2/issue244
Fix for #244
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -2398,7 +2398,22 @@ class Cmd2TestCase(unittest.TestCase): self.assertTrue(re.match(expected, result, re.MULTILINE | re.DOTALL), message) def _transform_transcript_expected(self, s): - """parse the string with slashed regexes into a valid regex""" + """parse the string with slashed regexes into a valid regex + + Given a string like: + + Match a 10 digit phone number: /\d{3}-\d{3}-\d{4}/ + + Turn it into a valid regular expression which matches the literal text + of the string and the regular expression. We have to remove the slashes + because they differentiate between plain text and a regular expression. + Unless the slashes are escaped, in which case they are interpreted as + plain text, or there is only one slash, which is treated as plain text + also. + + Check the tests in tests/test_transcript.py to see all the edge + cases. + """ regex = '' start = 0 |