Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: select and wildcards
Pages: [1] Print
Author Topic: select and wildcards  (Read 285 times)
fhein
Newbie
*
Offline Offline

Posts: 47


View Profile
select and wildcards
« on: May 09, 2005, 05:15:12 PM »

Could someone please give an example of how to use select/any? It didn't work the way I thought it would Sad
Logged
CarlRead
Full Member
***
Offline Offline

Posts: 105


View Profile
select and wildcards
« Reply #1 on: May 10, 2005, 01:00:33 AM »

Select returns the value after the match, thus...
Code:
>> str: "abc123def456"
== "abc123def456"
>> select str "123"
== #"d"
>> select/any str "12?"
== #"d"
>> select/any str "c*3"
== #"d"
If that doesn't solve your problem, describe more fully the type of results you want/expect.
Logged

- Carl Read
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
select and wildcards
« Reply #2 on: May 10, 2005, 04:48:52 AM »

/ANY doesn't work with blocks, if that's what you were after. It only works for strings.
Logged
fhein
Newbie
*
Offline Offline

Posts: 47


View Profile
select and wildcards
« Reply #3 on: May 10, 2005, 03:44:33 PM »

Yeah, I was trying to use it on a bunch of blocks. Thanks for the example too!
Logged
Gabriele
Full Member
***
Offline Offline

Posts: 182


View Profile WWW
select and wildcards
« Reply #4 on: May 11, 2005, 05:27:12 AM »

For blocks, you could use something like:

Code:
select-any: func [block string] [
   foreach [key value] block [
       if find/any key string [return :value]
   ]
]

Example:

Code:
>> select-any ["abc" 1 "def" 2] "a?c"
== 1
>> select-any ["abc" 1 "def" 2] "d*"
== 2
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: select and wildcards
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 20, 2008, 09:57:21 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2287 Posts in 593 Topics by 3727 Members
Latest Member: Maximinioles

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc