forked from cfengine/design-center
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redmine#2038: document string_split() and deprecation of splitstring()
- Loading branch information
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
layout: default | ||
title: string_split | ||
categories: [Reference, Functions, string_split] | ||
published: true | ||
alias: reference-functions-string_split.html | ||
tags: [reference, data functions, functions, string_split] | ||
--- | ||
|
||
[%CFEngine_function_prototype(string, regex, maxent)%] | ||
|
||
**Description:** Splits `string` into at most `maxent` substrings wherever | ||
`regex` occurs, and returns the list with those strings. | ||
|
||
The regular expression is [unanchored][unanchored]. | ||
|
||
If the maximum number of substrings is insufficient to accommodate all | ||
the entries, the generated `slist` will have `maxent` items and the | ||
last one will contain the rest of the string starting with the | ||
`maxent-1`-th delimiter. This is standard behavior in many languages | ||
like Perl or Ruby, and different from the `splitstring()` behavior. | ||
|
||
[%CFEngine_function_attributes(string, regex, maxent)%] | ||
|
||
**Example:** | ||
|
||
[%CFEngine_include_snippet(string_split.cf, #\+begin_src cfengine3, .*end_src)%] | ||
|
||
Output: | ||
|
||
[%CFEngine_include_snippet(string_split.cf, #\+begin_src\s+example_output\s*, .*end_src)%] | ||
|
||
**History:** Introduced in CFEngine 3.6; deprecates `splitstring()`. | ||
|
||
**See also:** `splitstring()` | ||
|