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

DSL: Get substring index (i.e. strings.Index())? #1225

Closed
archetyped opened this issue Mar 9, 2023 · 4 comments
Closed

DSL: Get substring index (i.e. strings.Index())? #1225

archetyped opened this issue Mar 9, 2023 · 4 comments
Assignees

Comments

@archetyped
Copy link

Apologies if this is referenced elsewhere, but in Miller's DSL, is there a way to search for a substring within a string and return the substring's position in the string?

Basically something like Go's strings.Index() method:

idx := strings.Index("or", "Ready or Not")
// Returns: 7
@johnkerl johnkerl self-assigned this Mar 10, 2023
@johnkerl
Copy link
Owner

@archetyped great idea! :)

@johnkerl
Copy link
Owner

@archetyped Go's strings.Index takes the substring as the second arg, not the first.

PR #1247 follows this convention -- but is of course 1-up with its indices since Miller is 1-up.

@johnkerl
Copy link
Owner

https://miller.readthedocs.io/en/main/reference-dsl-builtin-functions/#index

@archetyped
Copy link
Author

@archetyped Go's strings.Index takes the substring as the second arg, not the first.

Indeed, I got it flipped turned upside down.

Looks great! Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@johnkerl @archetyped and others