uce/site/doc/pages/nibble.txt

23 lines
652 B
Plaintext

:sig
String nibble(String& haystack, String delim)
:params
haystack : string to be nibbled at
delim : delimiter
return value : string before first occurrence of 'delim'
:see
>string
:content
Returns the part of `haystack` before the first occurrence of `delim`.
As a side effect, the consumed portion is removed from `haystack`, including the delimiter itself.
If `delim` does not occur in `haystack`, the entire string is returned and `haystack` is set to an empty string.
Related:
- PHP: small parsing helpers built with `strpos()`, `substr()`, and `explode()`
- JavaScript / Node.js: manual parsing with `indexOf()`, `slice()`, and `split()`