docs: clarify what str.split does

The wording was a bit confusing and misled at least one person into
thinking it behaved like `str.replace('c', '')` operating on the entire
line. Tweak the wording to be more precise and avoid this confusion.
pull/12037/head
Eli Schwartz 2 years ago
parent 9eb7fe332f
commit 1b8dcbcc57
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 4
      docs/markdown/Syntax.md
  2. 8
      docs/yaml/elementary/str.yml

@ -252,13 +252,13 @@ s = s.replace('as', 'are')
#### .strip()
```meson
# Similar to the Python str.strip(). Removes leading/ending spaces and newlines
# Similar to the Python str.strip(). Removes leading/ending spaces and newlines.
define = ' -Dsomedefine '
stripped_define = define.strip()
# 'stripped_define' now has the value '-Dsomedefine'
# You may also pass a string to strip, which specifies the set of characters to
# be removed.
# be removed instead of the default whitespace.
string = 'xyxHelloxyx'.strip('xy')
# 'string' now has the value 'Hello'
```

@ -61,7 +61,10 @@ methods:
# str.strip()
- name: strip
description: Removes leading/ending spaces and newlines from the string.
description: |
Removes leading/ending characters from the string.
By default the characters to remove are spaces and newlines.
returns: str
example: |
```meson
@ -75,7 +78,8 @@ methods:
strip_chars:
type: str
since: 0.43.0
description: All characters in this string will be stripped.
description:
description: Instead of whitespace, strip all the characters in this string.
# str.to_lower()
- name: to_lower

Loading…
Cancel
Save