Logo

Programming-Idioms

History of Idiom 96 > diff from v25 to v26

Edit summary for version 26 by Nepta:
New Lua implementation by user [Nepta]

Version 25

2016-09-27, 11:27:15

Version 26

2016-11-05, 03:49:51

Idiom #96 Check string prefix

Set boolean b to true if string s starts with prefix prefix, false otherwise.

Illustration

Idiom #96 Check string prefix

Set boolean b to true if string s starts with prefix prefix, false otherwise.

Illustration
Code
b = s:find(prefix) == 1
Comments bubble
no specialized function to do it, you could use pattern matching too
Doc URL
http://www.lua.org/manual/5.3/manual.html#pdf-string.find
Demo URL
http://codepad.org/QYdpi3iX