-
Notifications
You must be signed in to change notification settings - Fork 27
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
Support RegExp #43
Comments
Just like JSON is purely for data notation, I don't think CSON should support regular expressions. It's a form of executable code that could be misused. In your case, you could put it in a string and pass it into |
I don't know, since it maps 1:1 to a string, it could arguably be called "data". Since we don't support unquoted strings, there shouldn't be a problem. |
@phaux Thanks for bringing this up, btw. As for more arguments in favor of support: We already support static/const expressions for numeric operations. Which is even more similar to "executable code". But we'd have to figure out what we want to support in detail (e.g. coffee-script regex support is not just simple regex literals IIRC). |
@khoomeister There's a few problems with using strings to contain regexes:
The only downside I can think of is that it's not obvious what the JSON representation of {
"v": {
"$regexp": "abc",
"$flags": "gi"
}
} Or maybe it's not that important? |
There's no 1:1 mapping between CSON and JSON (see: |
I like the idea, but it doesn't feel right. As CSON is a declarative language, if there were ever a standard for CSON and parsers made in other languages I would personally omit this aspect because Regex is represented many different ways throughout multiple languages, where as things like numbers, strings, etc. have some uniformity across languages. |
This is now blocking noseglid/atom-build#178 😿 |
@jamen I think that's not necessarily a concern. E.g. there's precedent in projects like https://github.com/ua-parser/uap-core/blob/master/regexes.yaml where the same set of regexes, in that case stored in a yaml file, is shared across many languages. @dnalot I'll try to figure out how much it would take to add support. |
Added supported in v1.3.0 |
Example:
JS Equivalent:
I tried it while writing a custom atom editor syntax plugin and was surprised that it doesn't work.
The text was updated successfully, but these errors were encountered: