question about find function

new topic     » topic index » view thread      » older message » newer message

euphoria 4.0.5 Windows 10

This one gets me every now and then. Something I am not seeing but for the life of me...
Yes, match() works.
Any thoughts would be appreciated.

include std/console.e 
 
sequence haystack = "just in time" 
object needle = "in" 
printf (1,"location = %d\n",eu:find(needle,haystack)) 
any_key("<cr>") 


Returns a zero, meaning not found.

From the documentation:

8.15.2.1 find

<built-in> function find(object needle, sequence haystack, integer start)

Find the first occurrence of a "needle" as an element of a "haystack", starting from position "start"..
Parameters:

needle : an object whose presence is being queried
haystack : a sequence, which is being looked up for needle
start : an integer, the position at which to start searching. Defaults to 1.

Returns:

An integer, 0 if needle is not on haystack, else the smallest index of an element of haystack that equals needle.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu