Template:Str left long/doc

From 'City of Adelaide' History and Genealogy Site
Jump to navigation Jump to search

{{#invoke:Message box|mbox}} {{#invoke:Lua banner|main}}

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: {{ safesubst:#invoke:String|sub|abcdef|1|7 }}
  • {{str left long|255.32|2}} gives: {{ safesubst:#invoke:String|sub|255.32|1|2 }}
  • {{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 wp: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