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

fix #15723, findfirst on strings #23592

Merged
merged 1 commit into from
Sep 6, 2017
Merged

fix #15723, findfirst on strings #23592

merged 1 commit into from
Sep 6, 2017

Conversation

JeffBezanson
Copy link
Sponsor Member

Makes findfirst, findlast, findnext, and findprev more generic by using endof, nextind, and prevind. Also adds a nextind method for arrays and CartesianIndex.

These functions are scheduled for a refactoring, but in the meantime might as well make them work better.

@JeffBezanson JeffBezanson added the domain:strings "Strings!" label Sep 5, 2017
Makes findfirst, findlast, findnext, and findprev more generic
by using endof, nextind, and prevind. Also adds a `nextind` method
for arrays and `CartesianIndex`.
Copy link
Member

@nalimilan nalimilan left a comment

Choose a reason for hiding this comment

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

That doesn't fix the issue of general iterables, but it's great to get support for strings with so minimal changes.

Since it took me some time to find it, the PR about supporting any iterable is #18668.

@@ -379,3 +379,9 @@ end
@test rsearchindex("\U1f596\U1f596", "\U1f596\U1f596", endof("\U1f596\U1f596\U1f596")) == 1

@test_throws ErrorException "ab" ∈ "abc"

# issue #15723
Copy link
Member

Choose a reason for hiding this comment

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

Could be worth testing other cases for each function, e.g. with the searched character is in the middle of the string (with non-ASCII chars around it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants