Movatterモバイル変換


[0]ホーム

URL:


CFEngine documentation homepage

parsestringarray

Suggest changes
Table of contents

Prototype:parsestringarray(array, input, comment, split, maxentries, maxbytes)

Return type:int

Description: Parses up tomaxentries values from the firstmaxbytesbytes in stringinput and populatesarray. Returns the dimension.

These functions mirrors the exact behavior ofreadstringarray(), but read data from a variableinstead of a file. By making data readable from a variable, data drivenpolicies can be kept inline.

Thecomment field is a multiline regular expression and will strip outunwanted patterns from the file being read, leaving unstripped characters to besplit into fields. Using the empty string ("") indicates no comments.

Arguments:

  • array : Array identifier to populate, in the range[a-zA-Z0-9_$(){}\[\].:]+
  • input : A string to parse for input data, in the range"?(/.*)
  • comment :Unanchored regex matching comments, in the range.*
  • split :Unanchored regex to split data, in the range.*
  • maxentries : Maximum number of entries to read, in the range0,99999999999
  • maxbytes : Maximum bytes to read, in the range0,99999999999

Example:

code
bundleagent__main__{vars:######################################## Define data inline for convenience#######################################"table"string=>"Eulers Number:2.718A Feigenbaum constant:4.6692Tau (2pi):6.28";#######################################"dim"int=>parsestringarray("items","$(table)","\s*#[^\n]*",":","1000","200000");"keys"slist=>sort(getindices("items"));reports:"$(keys) -$(items[$(keys)][1])";}

Output:

code
R: A Feigenbaum constant - 4.6692R: Eulers Number - 2.718R: Tau (2pi) - 6.28

History: Was introduced in version 3.1.5a1, Nova 2.1.0 (2011)

See also:parserealarray(),parseintarray(),readstringarray(),readintarray(),readrealarray()

Still need help?

Chat Ask a question on Github Mailing list
Version 
master3.24 (LTS)3.21 (LTS)view all versions

[8]ページ先頭

©2009-2025 Movatter.jp