suve

awful: function: str-pos

Declaration

int :str-pos ( string $NEEDLE , string $HAYSTACK )

Summary

Searches for NEEDLE in HAYSTACK. If found, returns the character index of the first occurence. Otherwise, returns 0.

Example

# :str-pos example
:set &NAME s''
:writeln s"What's your name?"
:readln &NAME
!if :str-pos s"a" $NAME
    :writeln s"Hello, " $NAME s"."
!else
    :writeln s"Wow, " $NAME s", your name does not contain an 'a'! Amazing!"
!fi

wikipage modified on 2014/0601/2317