[ create a new paste ] login | about

Link: http://codepad.org/MfwkcgP6    [ raw code | output | fork ]

Lua, pasted on Mar 3:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
s = "Ohio"

prefix = "Oh"
b = s:find(prefix, 1, true) == 1
if b then
    print(string.format("%q starts with %q", s, prefix))
else
    print(string.format("%q does not start with %q", s, prefix))
end

prefix = "Oh?"
b = s:find(prefix, 1, true) == 1
if b then
    print(string.format("%q starts with %q", s, prefix))
else
    print(string.format("%q does not start with %q", s, prefix))
end


Output:
1
2
"Ohio" starts with "Oh"
"Ohio" does not start with "Oh?"


Create a new paste based on this one


Comments: