Skip to content

Add pattern test for trailing newline #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zac-HD opened this issue Oct 4, 2019 · 2 comments · Fixed by #284
Closed

Add pattern test for trailing newline #283

Zac-HD opened this issue Oct 4, 2019 · 2 comments · Fixed by #284

Comments

@Zac-HD
Copy link
Contributor

Zac-HD commented Oct 4, 2019

Follow-up to #282, since I left it out there: ^abc$ should match abc but not abc\n. This is a useful test because both will match in Python, absent special handling such as js-regex.

@awwright
Copy link
Member

awwright commented Oct 4, 2019

Does Python default to multiline matching?

ECMAScript does not:

"abc\n".match(/abc$/);
null
"abc\n".match(/abc$/m);
[ 'abc', index: 0, input: 'abc\n', groups: undefined ]

Aside, what if someone wants to do a multiline match?

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Oct 4, 2019

Python doesn't default to multiline matching, but for reasons I won't pretend to understand has the behaviour above. Python's equivalent of ECMAScript $ is \\Z, so js-regex can translate but IMO it's a good idea to have an upstream test for this.

The JSON-schema spec does not give any way to use multiline mode, so you'd need to include newlines (or whatever else) in your pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants