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

Add examples for Re.split function #216

Merged
merged 3 commits into from
Jul 13, 2024

Conversation

mooreryan
Copy link
Contributor

Adds a few examples of using zero-length patterns as inputs to Re.split. Examples are taken from the test suite. Related to #119 and #120.

I know it is an old issues (this one: #119), but I also tried to use the eol as input for split in the past. So, I took a couple of the test cases and added them to the examples for Re.split.

@mooreryan
Copy link
Contributor Author

Looks like the build is failing due to the dependency on core_bench for the benchmarks.

lib/core.mli Outdated
@@ -280,6 +280,22 @@ val split : ?pos:int -> ?len:int -> re -> string -> string list
# Re.split ~pos:3 regex "1,2,3,4. Commas go brrr.";;
- : string list = ["3"; "4. Commas go brrr."]
]}

Be careful when using [split] with zero-length patterns like [eol], [bow],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you should explain what to be careful about, as it's kind of vague even with the examples. I get the general idea, but I think this could be explained in more detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added more details in the latest commit.

@mooreryan
Copy link
Contributor Author

mooreryan commented Jul 11, 2024

Any interest in this PR? If so I could resolve the conflicts, if not, I will close it.

@rgrinberg
Copy link
Member

Sure, I think this PR is useful. Ping me when it's ready and I'll merge.

Adds a few examples of using zero-length patterns as inputs to Re.split.  Examples are taken from the test suite.  Related to ocaml#119 and ocaml#120.
Adds a few examples of using zero-length patterns as inputs to Re.split_delim.  Examples are taken from the test suite.  Related to ocaml#119 and ocaml#120.
@mooreryan
Copy link
Contributor Author

Thanks @rgrinberg, I rebased, and added corresponding examples to the split_delim function as well, since its behavior is a bit different than split.

@rgrinberg rgrinberg merged commit 4aac04a into ocaml:master Jul 13, 2024
3 of 7 checks passed
@rgrinberg
Copy link
Member

Thanks!

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