-
Notifications
You must be signed in to change notification settings - Fork 2
Multiline Regexp by also ignoring linebreaks #5
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
Comments
That's probably not feasible. Implementations are adamant that they will not change how https://tc39.es/ecma262/#prod-RegularExpressionLiteral parses. In addition, that would be a breaking syntactic change due to ASI: a
/
b
/x Is legal JS, and a multiline RegExp would make this ambiguous or require a fairly complex cover grammar. Some of these limitations are also being discussed in #1 as it pertains to what is allowed inside of a |
This is a very fascinating reply 🤩 that I think in itself would definitely enrich the readme. That said I find this proposal a lot less appealing without dedicated support for Multiline regexp Grammar (preferably not conflicting with existing grammar 😅) as I would like IDE support (code highlighting, linting and inline docs) for Multiline regexp. If I have to put it in a string something like this is syntax highlighted. x = new RegExp(
'[0-9]{1,4}' // the first few digits
) Maybe an alternative Syntax like:
Could work out? |
Unfortunately, the The most likely scenario is using a template literal. The examples I've made so far use this: x = new RegExp(String.raw`
[0-9]{1,4} # the first few digits
`, "x"); The template isn't so bad because |
You lost me there, but maybe my suggestion was poor. I was trying to suggest that [
My concern is not about the escaping of content, thought that is annoying, its more about the absence of reliable syntax highlighting. Rethinking this once more: would it be possible to have Regexp have a multiline helper that Syntax highlighter could treat differently? x = RegExp.multiline`
[0-9]{1,4} # the first few digits
` As I recently noticed that Python IDE's do format similar r'[0-9]{1,4}' |
Perl does
This proposal has been stalled for a while. It would really help as regex easily become line noise without spacing. Having linebreaks is pretty important! Any movement? |
Multi-line mode is a must. Currently implemented via transform-modern-regexp plugin that uses re`/
# A regular expression for date.
(?<year>\d{4})- # year part of a date
(?<month>\d{2})- # month part of a date
(?<day>\d{2}) # day part of a date
/x`; |
It seems like a low hanging fruit to also ignore linebreaks as characters that are ignored in
x
mode that would open the door to good multi-line RegExp definitions.It maybe good to have an FAQ explainer that explains this absence (or support it)
The text was updated successfully, but these errors were encountered: