ParseLines (String function): Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 8: | Line 8: | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%sl</th> | ||
<td>A <var>Stringlist</var> object to contain as its items the identified substrings of the method object, <var class="term">string</var>.</td></tr> | <td>A <var>Stringlist</var> object to contain as its items the identified substrings of the method object, <var class="term">string</var>.</td></tr> | ||
Line 16: | Line 16: | ||
<tr><th>delims</th> | <tr><th>delims</th> | ||
<td>A string that is a list of one or more line delimiters that determine the substrings that become <var class="term">% | <td>A string that is a list of one or more line delimiters that determine the substrings that become <var class="term">%sl</var> <var>Stringlist</var> items. If specified, the first character in the delimiter list is the separator character for the delimiter list itself, and the remainder are the delimiters to be used to separate <var class="term">string</var> into substrings. | ||
<p> | <p> | ||
If this optional argument is not specified, the delimiter list that applies is <code>X'0D'</code>, <code>X'25'</code>, and <code>X'0D25'</code> (which are the EBCDIC carriage-return, line-feed, and carriage-return/line-feed characters respectively). These should handle any line-end delimited data from an ASCII host that is been translated to ASCII.</p></td></tr> | If this optional argument is not specified, the delimiter list that applies is <code>X'0D'</code>, <code>X'25'</code>, and <code>X'0D25'</code> (which are the EBCDIC carriage-return, line-feed, and carriage-return/line-feed characters respectively). These should handle any line-end delimited data from an ASCII host that is been translated to ASCII.</p></td></tr> |
Revision as of 21:45, 2 November 2012
Parse delimited string, creating new Stringlist (String class)
ParseLines creates a Stringlist whose items are substrings of a given string. The substrings are determined by a user-identified delimiter string.
Syntax
%sl = string:ParseLines[( [delims], [StripTrailingNull= boolean])]
Syntax terms
%sl | A Stringlist object to contain as its items the identified substrings of the method object, string. |
---|---|
string | The string to be parsed to provide the content of the %sl Stringlist. |
delims | A string that is a list of one or more line delimiters that determine the substrings that become %sl Stringlist items. If specified, the first character in the delimiter list is the separator character for the delimiter list itself, and the remainder are the delimiters to be used to separate string into substrings.
If this optional argument is not specified, the delimiter list that applies is |
StripTrailingNull | This name required argument is a boolean value that indicates whether a trailing null line should be stripped. StripTrailingNull is an optional argument that defaults to true, which results in a trailing null line being stripped. |
Usage notes
- The CreateLines function performs the inverse operation; that is, it creates a string by concatenating the items in a Stringlist with separator strings between the items.
Examples
If Longstring %ls
is 'every,good,boy,does,fine'
,
and %sl
is a Stringlist, and you specify:
%sl = %ls:parselines(' ,') %sl:print
The result is:
every good boy does fine