Check if REBOL line contains another line

I tried using a function findto check for the presence of a string "ll"in a string "hello", but it returns "ll"instead of trueor false:

"This prints 'll'"
print find "hello" "ll"

Are there any functions in the REBOL standard library to check if a string contains another string?

+4
source share
3 answers

try it

>> print found? find "hello" "ll"
true
>> print found? find "hello" "abc"
false
+5
source

@ShixinZeng right, what is FOUND? in Rebola. However, it is simply defined as:

found?: function [
    "Returns TRUE if value is not NONE."
    value
] [
    not none? :value
]

How is it equivalent not none?... you could write:

>> print not none? find "hello" "ll"
true
>> print not none? find "hello" "abc"
false

Or if you want a different offset:

>> print none? find "hello" "ll"
false
>> print none? find "hello" "abc"
true

FIND. , , , , FIND, .

>> if found? 1 + 2 [print "Well this is odd..."]
Well this is odd...

FIND IF UNLESS EITHER, ... , . NOT NONE? ? .

, , FOUND? .

+1

find, , .

>> either find "hello" "ll" [
[    print "hit"
[    ] [
[    print "no hit"
[    ]
hit

>> print either find "hello" "ll" [ "hit"] [ "no hit"]
hit

to-logic , true false

>> print to-logic find "hello" "ll"
true
>> print  find "hello" "lzl"                 
none
>> print  to-logic find "hello" "lzl"
false
+1

All Articles