Template:Str left long

From Sarkarverse
Jump to navigation Jump to search

x

Documentation icon Template documentation[view] [edit] [history] [purge]

The Template:Str left long is a general utility, as a string-handling utility template, to extract the left-hand side of long text strings beyond 500 to thousands of characters long, using a Lua script module.

Usage

{{str left long|abcdef|3}} gives: abc

Examples

  • {{str left long|abcdef|2}} gives: ab
  • {{str left long|abcdef|5}} gives: abcde
  • {{str left long|abcdef|0}} gives: [nothing]
  • {{str left long|abcdef|7}} gives:String Module Error: String subset index out of range
  • {{str left long|255.32|2}} gives: 25
  • {{str left long|..60,000 long...|59999}} gives: ...59,999 long...

Performance considerations

Because {str_left_long} uses a Lua module, it depends on the speed of the Lua script processing, which in February 2013, ran at the speed of 180 per second for repeated uses of {str_left_long}. By comparison, the SV:parser function {padleft:} runs at over 1,250 per second, to extract the left-hand side of a string, but only up to 500 long.

See also