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

Regex Atoms #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

jared-hughes
Copy link

  • œF: Regex Findall: Find all instances of regex x in string y; return a list of matches
  • œḞ: Regex Finditer: Find all instances of regex x in string y; return a list of lists of groups
  • œṠ: Regex Sub: Take arguments substitution configuration [x1,x2] and y. Substitute all instances of regex x1 with replacement string x2 in string y.
  • œR: Regex Search: Give a boolean denoting if regex x matches string y in any position.
  • œṢ: Regex Split: Split string y at occurrences of regex x.
  • ÐR: Regex sub quick: <regex><sub>ÐR replaces all occurrences of <regex> with <sub> applied to each occurrence’s list of groups and span

Some possible issues:

  • If œṠ is given a left argument/configuration which is a string, it substitutes all instances of the first character of the string with the second character of the string in the right argument, which is the same as atom y.
  • ÐR uses to_string(x) = ''.join(x) if is_string(x) else str(x) to cast the output of <sub> to string. Not sure if there is a better casting method.

@jared-hughes jared-hughes changed the title Jelly regex Regex Atoms Oct 1, 2017
@GolfingSuccess
Copy link
Contributor

I suggest making œṠ to act more likey, i.e. [x1, x2, x3, x4] would substitute x1 with x2 and x3 with x4, with earlier matches having priority.

- œṠ works like link y now
- ÐR applies all regexps in link[0] in order if link[0] is a list of strings/regexps
@DennisMitchell
Copy link
Owner

A few issues:

  1. I'm currently unable to test this because line 1 of jelly.py changed both on master and here. I think that could be resolved by re-adding parser, but I'll see if I can resolve the conflicts in another way.

  2. Many of new the atoms returns str. Jelly doesn't have a string type, so this is bound to cause issues. A single str can be cast to list.

  3. œR returns bool, which is another type Jelly doesn't have.

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 this pull request may close these issues.

3 participants