-
Notifications
You must be signed in to change notification settings - Fork 163
Open
Description
Where is the problem?
In the documentation for Str\trim, both in the explanation and the examples.
What is the problem?
The page does not explain what happens if the optional character mask is provided. I think something like:
"If the character mask is provided, all occurrences of characters in $char_mask will be trimmed from beginning and end. Note that order of characters in $char_mask does not matter."
I think it would be nice to add an example "gotcha".
For example:
// POTENTIAL GOTCHA
$s = Str\trim('/user/home/mydocs/', '/user/home/');
// Gives 'ydoc`, when a user may be expecting `mydocs/`Reference
I've seen this "gotcha" with python s.strip() as well. It appears trim operates the same way.
https://docs.python.org/3/library/stdtypes.html#str.strip
Note
Duplicate language or maybe just a "See the gotcha in Str\trim should probably be added to the other trim functions.
- Build ID: HHVM=HHVM-4.164.0:HSL=v4.108.1:2024-02-08T13:44:46+0000:1fa47f258c6b68f8ec01899aa82fd6ffa0957109
- Page requested: /hsl/reference/function/HH.Lib.Str.trim/
- Page requested at: Mon, 04 Aug 2025 21:13:10 +0000
- Controller: APIClassPageController
Metadata
Metadata
Assignees
Labels
No labels