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

Added possibility to strip left and right to strip_edges #4594

Merged
merged 3 commits into from
May 11, 2016
Merged

Added possibility to strip left and right to strip_edges #4594

merged 3 commits into from
May 11, 2016

Conversation

mattiascibien
Copy link
Contributor

@mattiascibien mattiascibien commented May 9, 2016

Added two optional parameters to strip_edges in order to strip only left and only right part of the string. This are defaulted to true to ensure compatibility with current stripping mechanic.

Also optimizes the call by replacing calls to length() with a local variable

Fixes #968

If needed I can squish commits.

Use len variable instead of calling length() every time.
* Accepts left for stripping on the left of the string
* Accepts right for stripping on the right of the string
@bojidar-bg
Copy link
Contributor

@mattiascibien ~ What about telling it which characters to strip (like python..)? E.g. I might want it to remove newlines, but leave spaces intact 😄

@mattiascibien
Copy link
Contributor Author

@bojidar-bg I wanted to wait for input on this as i think it is going to break compatibility

@bojidar-bg
Copy link
Contributor

@mattiascibien ~ You can always give it a sane default value, like " \n\r\t", or just use "\x00\x01\x02…\x31\x32"

@mattiascibien
Copy link
Contributor Author

@bojidar-bg I will have a look into it. The problem now is the order of parameters. The characters to be replaced should be the third one in my opinion as using it as the first will prevent doing things like strip_edges(true,false) for example.

@akien-mga akien-mga merged commit 49c473b into godotengine:master May 11, 2016
@mattiascibien mattiascibien deleted the new-string-methods branch May 11, 2016 08:16
akien-mga pushed a commit that referenced this pull request May 12, 2016
@aaronfranke aaronfranke added this to the 2.1 milestone Jan 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

String.trim() String.left_trim() String.right_trim()
5 participants