Skip to content
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

Regular expression support #3

Open
randy3k opened this issue Feb 12, 2018 · 7 comments
Open

Regular expression support #3

randy3k opened this issue Feb 12, 2018 · 7 comments
Assignees

Comments

@randy3k
Copy link
Member

randy3k commented Feb 12, 2018

From @kylebarron on October 2, 2017 4:56

Add regular expression support, similar to the implementations in language-python and language-stata.
image

This is non-trivial in R because it's harder to tell when a string is used to match something else, or when it's a literal string, and it should be matched. I looked through documentation and in general, the functions that have the regex in the first slot are grep grepl regexpr gregexpr sub gsub regexec regex, and the functions that have it in the second slot are

\\b(strsplit|stri_(count|detect|extract|locate|match|replace|split|startswith|endswith|subset)[_a-z]*|str_(count|detect|split|subset|which)|str_(extract|locate|match|replace|view)(_all)?)

Hopefully I'll be able to use this to color the object in the first or second slot for those functions.

Note to self: Don't use syntax highlighting withing a fixed() call.

Copied from original issue: REditorSupport/atom-language-r-legacy#5

@randy3k
Copy link
Member Author

randy3k commented Feb 12, 2018

R regex string is just a regular string. Not sure how to implement it.

@randy3k
Copy link
Member Author

randy3k commented Feb 12, 2018

From @kylebarron on October 2, 2017 15:41

I tentatively got very basic functionality a while ago (with just assuming that a string in the first or second slot is meant to be the regex string). I'll try to add that into this repo.

@randy3k
Copy link
Member Author

randy3k commented Feb 12, 2018

From @guillaumechaumet on October 2, 2017 15:48

By predicting every possibility like @kylebarron, it's possible. Nice job @kylebarron

@randy3k
Copy link
Member Author

randy3k commented Feb 12, 2018

But the patterns can be stored as variables and then later be used in grep/sub etc

@randy3k
Copy link
Member Author

randy3k commented Feb 12, 2018

From @kylebarron on October 2, 2017 15:57

Yeah, it's not possible to get every pattern colored, but I personally think it's still worth it to color patterns in the most popular use cases.

@randy3k
Copy link
Member Author

randy3k commented Feb 12, 2018

Hmm, you may also want to include stringr and stringi

@randy3k
Copy link
Member Author

randy3k commented Feb 12, 2018

From @kylebarron on October 3, 2017 14:25

Those are included... Pretty much all of

\\b(strsplit|stri_(count|detect|extract|locate|match|replace|split|startswith|endswith|subset)[_a-z]*|str_(count|detect|split|subset|which)|str_(extract|locate|match|replace|view)(_all)?)

come from the stringr and stringi packages.

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

No branches or pull requests

2 participants