diff options
-rw-r--r-- | lib/LSL.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/LSL.lua b/lib/LSL.lua index 571ecf1..09f6ba8 100644 --- a/lib/LSL.lua +++ b/lib/LSL.lua | |||
@@ -722,11 +722,24 @@ function --[[string]] LSL.llGetSubString(--[[string]] text, --[[integer]] start, | |||
722 | end | 722 | end |
723 | 723 | ||
724 | function --[[integer]] LSL.llSubStringIndex(--[[string]] text, --[[string]] sub) | 724 | function --[[integer]] LSL.llSubStringIndex(--[[string]] text, --[[string]] sub) |
725 | if nil == text then return -1 end | ||
726 | if nil == sub then return -1 end | ||
725 | local start, End = string.find(text, sub, 1, true) | 727 | local start, End = string.find(text, sub, 1, true) |
726 | 728 | ||
727 | if nil == start then return -1 else return start - 1 end | 729 | if nil == start then return -1 else return start - 1 end |
728 | end | 730 | end |
729 | 731 | ||
732 | function LSL.llStringTrim(--[[string]] text, --[[integer]] Type) | ||
733 | -- Trims spaces (ASCII 32), tabs (ASCII 9) '\t', and new lines (ASCII 10) '\n' | ||
734 | -- Lua doesn't document what it considers to be "space characters" | ||
735 | if (Type == LSL.STRING_TRIM_HEAD) or (Type == LSL.STRING_TRIM) then | ||
736 | text = string.gsub(text, '^%s*(.*)', '%1') | ||
737 | end | ||
738 | if (Type == LSL.STRING_TRIM_TAIL) or (Type == LSL.STRING_TRIM) then | ||
739 | text = string.gsub(text, '(.-)%s*$', '%1') | ||
740 | end | ||
741 | return text | ||
742 | end | ||
730 | 743 | ||
731 | -- Crements stuff. | 744 | -- Crements stuff. |
732 | 745 | ||