Table Of Contents

Scan from String (G Dataflow)

Version:
    Last Modified: March 3, 2017

    Scans a string for text that matches a specified format, returning these matches in the form of specified data types.

    connector_pane_image
    datatype_icon

    format string

    A string that includes a format specifier for each output. This string also includes any additional text that you know appears in the input string, but which you do not want to appear in an output. A format specifier is a series of characters, initiated by a %, that indicates how to convert a series of characters into an output.

    Each format specifier uses the following general syntax:

    % width specifier

    This input accepts a maximum of 255 characters.

    Specifiers

    Specifier Definition
    x hexadecimal integer
    o octal integer
    b binary integer
    d signed decimal integer
    u unsigned decimal integer
    f floating-point number with fractional format
    e floating-point number in scientific notation
    g floating-point number in either fractional format (f) or scientific notation (e) depending on the exponent of the number:
    • f—The exponent is greater than -4 and less than the precision specified
    • e—exponent is less than -4 or greater than the precision specified
    ^e or ^g floating-point number in engineering notation
    p floating-point number in SI notation
    s string. This specifier scans to the next whitespace character. If the current scanning location begins with a whitespace character, the node scans all contiguous whitespace.
    [ ]

    character combinations from within a specified set. [ ] matches a string that contains any combination of the characters specified between the brackets. Character matches are case sensitive.

    You can specify a range of characters by using a -. For example, [0-9a-zA-Z ] matches any string that contains numbers, letters, or spaces.

    You can exclude characters from the scan by using ^ as the first character in the set. For example, [^,;] matches any string of characters up to but not including the first comma or semicolon.

    To allow hyphens within the character set, specify it as the first or last character in the set.

    To allow ^ within the character set, include it anywhere other than as the first character in the set.

    T absolute time, most commonly used to interpret timestamp data
    t relative time, most commonly used to interpret numeric data as elapsed seconds

    Syntax for Matching Literal Text That You Do Not Want To Output

    Syntax Definition
    \00 - \FF Hex value of an 8-bit character; must be uppercase
    \b Backspace (ASCII BS, equivalent to \08)
    \f Form feed (ASCII FF, equivalent to \0C)
    \n Linefeed (ASCII LF, equivalent to \0A). Format into File automatically converts this code into the platform-dependent end-of-line character.
    \r Carriage return (ASCII CR, equivalent to \0D)
    \t Tab (ASCII HT, equivalent to \09)
    \s Space (equivalent to \20)
    \\ Backslash (ASCII \, equivalent to \5C)
    %% Percent sign
    non-escaped spaces Any contiguous spaces in the format string match any whitespace in the input string, including new lines and tabs.

    Default: Empty string — Causes this node to scan the text according to the default behavior for the data types of the wired outputs.

    datatype_icon

    input string

    The string this node searches for data to format.

    datatype_icon

    initial scan location

    The number of bytes into the string at which the scan begins.

    spd-note-note
    Note  

    Strings are encoded in UTF-8. For strings containing characters in the U+0000 through U+007F range, the number of bytes in a string is equivalent to the number of characters. However, for strings containing the characters U+0080 through U+7FFFFFFF, the number of bytes is greater than the number of characters.

    Default: 0

    datatype_icon

    error in

    Error conditions that occur before this node runs.

    The node responds to this input according to standard error behavior.

    Standard Error Behavior

    Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

    error in does not contain an error error in contains an error
    If no error occurred before the node runs, the node begins execution normally.

    If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

    If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

    Default: No error

    datatype_icon

    default value

    Default data type and default value for the corresponding output parameter. The node uses this information only if you do not wire a string constant to format string. If you do wire a string constant to format string, the node uses the format specifiers in that constant to determine the data type of each output.

    Each default value can be a string, path, Boolean, enumerated type, timestamp, or numeric value. You cannot use arrays and clusters with this node.

    Implications of Using an Enumerated Type

    If you wire an enumerated type to default value, the node scans for substrings within the input text that match the string values in the enumerated type and returns the corresponding value of the enumerated type.

    Default: 0, double-precision floating point or empty string, string, depending on the output data type defined by format string

    datatype_icon

    remaining string

    Portion of the string that remains after scanning all arguments.

    datatype_icon

    offset past scan

    The index in input string of the first byte following the last scanned argument.

    spd-note-note
    Note  

    Strings are encoded in UTF-8. For strings containing characters in the U+0000 through U+007F range, the number of bytes in a string is equivalent to the number of characters. However, for strings containing the characters U+0080 through U+7FFFFFFF, the number of bytes is greater than the number of characters.

    datatype_icon

    error out

    Error information.

    The node produces this output according to standard error behavior.

    Standard Error Behavior

    Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

    error in does not contain an error error in contains an error
    If no error occurred before the node runs, the node begins execution normally.

    If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

    If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.
    datatype_icon

    output

    Output data obtained from a single format specifier in format string.

    The data type of this parameter matches the data type specified by the corresponding format specifier in format string or the corresponding default value. Possible data types include strings, paths, enumerated types, timestamps, and numerics, but not arrays and clusters. If you scan a string that does not fit into the numeric representation you specify, this node returns the largest number that fits into that representation.

    Does Whitespace Matter?

    If you set format string to return numeric values in the output parameters, white spaces in the input string are ignored. Otherwise, a single space in format string matches any amount of whitespace in the input.

    Scanning Values with Data Types Other Than Double-Precision Floating-Point

    format string determines what data types to expect in the input text. If you do not wire a string constant to format string, you must wire the expected data type for each expected output to the corresponding default value.

    Troubleshooting "Too few/many format specifiers." Error

    These errors occur when you wire a string to format string that contains a different number of format specifiers than there are output parameters. To fix this mismatch, either resize the node to display the same number of outputs as format specifiers, or modify the number of format specifiers in format string to match the number of output parameters.

    Troubleshooting "Format specifier type mismatch." Error

    This error occurs when you wire a string to format string that contains at least one format specifier whose data type specifier is incompatible with the data type of the corresponding output. The text of the error specifies which parameter caused the mismatch. To fix this mismatch, you must change either the data type specifier in the relevant format specifier or wire a compatible data type to the relevant output.

    input string format string default(s) output(s) remaining string

    abc, xyz

    12.3+56i 7200

    %3s, %s%f%2d

    -- abc 00
    -- xyz
    0+00i 12.3+56i
    -- 72
    Q+1.27E-3 tail Q%f t -- 1.27E-3 ail
    0123456789 %3d%3d -- 12 6789
    345
    X:9.860 Z:3.450 X:%fY:%f 100 (I32) 10 Z: 3450
    100.00 (DBL) 100.00
    set49.4.2 set%d -- 49 .4.2
    color: red color: %s blue (enum {red, green, blue}) red --
    abcd012xyz3

    %[a-z]%d

    %[a-z]%d

    -- abcd --
    12
    xyz
    3
    welcome to LabVIEW, John Smith %[^,],%s -- welcome to LabVIEW Smith
    John

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: DAQExpress does not support FPGA devices


    Recently Viewed Topics