REBOL Document

Find - Function Summary


Summary:

Finds a value in a series and returns the series at the start of it.

Usage:

find series value

Arguments:

series - The series argument. (must be: series port bitset)

value - The value argument. (must be: any-type)

Refinements:

/part - Limits the search to a given length or position.

range - The range argument. (must be: number series port)

/only - Treats a series value as a single value.

/case - Characters are case-sensitive.

/any - Enables the * and ? wildcards.

/with - Allows custom wildcards.

wild - Specifies alternates for * and ? (must be: string)

/skip - Treat the series as records of fixed size

size - The size argument. (must be: integer)

/match - Performs comparison and returns the tail of the match.

/tail - Returns the end of the string.

/last - Backwards from end of string.

/reverse - Backwards from the current position.

Description:

Returns NONE if the value was not found. Otherwise, returns a position in the series where the value was found. Many refinements to this function are available.

/TAIL indicates that the position just past the match should be returned.

The /MATCH refinement can be used to perform a character by character match of the input value to the series. The position just past the match is returned.

Wildcards can be specified with /ANY and case sensitive comparisons can be made with /CASE.

The /ONLY refinement applies to block values and is ignored for strings.

The /LAST refinement causes FIND to search from the TAIL of the series toward the HEAD.

/REVERSE searches backwards from the current position toward the head.


    probe find "here and now" "and"
    "and now"


    probe find/tail "here and now" "and"
    " now"


    probe find [12:30 123 c@d.com] 123
    [123 c@d.com]


    probe find [1 2 3 4] 5
    none


    probe find/match "here and now" "here"
    " and now"


    probe find/match "now and here" "here"
    none


    probe find [1 2 3 4 3 2 1] 2
    [2 3 4 3 2 1]


    probe find/last %file.fred.txt "."
    %.txt


    probe find/last [1 2 3 4 3 2 1] 2
    [2 1]


    probe find/any "here is a string" "s?r"
    "string"

Related:

pick - Returns the value at the specified position in a series.
select - Finds a value in the series and returns the value or series after it.


<Back | Index | Next>

Copyright 2004 REBOL Technologies