REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: find

find  series  value  /part  length  /only  /case  /any  /with  wild  /skip  size  /last  /reverse  /tail  /match

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

Arguments:

series [series! gob! port! bitset! typeset! object! none!]

value [any-type!]

Refinements:

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

length [number! series! pair!]

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

/case - Characters are case-sensitive

/any - Enables the * and ? wildcards

/with - Allows custom wildcards

wild [string!] - Specifies alternates for * and ?

/skip - Treat the series as records of fixed size

size [integer!]

/last - Backwards from end of series

/reverse - Backwards from the current position

/tail - Returns the end of the series

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

See also:

select   pick  

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.

Refinements

Use /tail to return the position just past the match.

Use /case to specify that the search should be case sensitive. Note that using find on a binary string will do a case-insensitive search.

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.

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.

And, /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"
none


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin