Difference between revisions of "Str.isin"

From OpenEUO
Jump to: navigation, search
m (Created page with "== Calling Pattern == Call local r,c = sl.str.isin(s1,s2) Args s1 is a string s2 is a string Results r is a boolean c is a number == Usage Example == local s = sl.str lo...")
 
(No difference)

Latest revision as of 16:40, 11 November 2010

Calling Pattern

Call

local r,c = sl.str.isin(s1,s2)

Args

s1 is a string
s2 is a string

Results

r is a boolean
c is a number

Usage Example

local s = sl.str
local i = 'This is a test'
local j = 'is'
local r,c = s.isin(i,j)
print(tostring(r)..' '..c)
--> true 3

Description

Determines if string s2 is a substring of string s1 and if so returns its position as well. See str.cnt for a similar function.

Upon Error

Isin fails silently. If s1 or s2 aren't strings, then nil is returned.

See Also