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 a substring modification #36

Merged
merged 6 commits into from
May 21, 2023
Merged

Conversation

arieroos
Copy link
Contributor

I sometimes get "yes" or "no" inputs, but I'm only interested in the first character ("y" or "n"). I think substring will be a handy addition, as it'll allow users of this library to discard or keep a certain amount of characters of their input.

I implemented substring with the following rules:
Tag syntax: substr:start[-end]

  • start and end is 0-indexed
  • If end is left unspecified, the substring will be taken from start to the end of the input.
  • If neither values are specified, the tag does nothing.
  • If start is greater than or equal to the length of the input, an empty string is returned.
  • The same happens if start is greater than or equal to end.
  • If end is greater than or equal to the length of the input, the substring is taken from start to the end of the input.

I think these rules are robust, intuitive, and simple for the client code to use.

@coveralls
Copy link

coveralls commented May 31, 2022

Coverage Status

Coverage: 96.418% (+0.2%) from 96.246% when pulling e59c970 on arieroos:master into 0215b84 on go-playground:master.

@deankarn deankarn merged commit 749a175 into go-playground:master May 21, 2023
11 checks passed
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.

None yet

3 participants