Tractor & Construction Plant Wiki
Advertisement

4

[edit] [purge] Template documentation

Usage

{{str find|text|sub_string}} = Position of first appearance of sub_string in text.

  • Returns -1 if sub_string is not found in first 10 characters, and the test is more than 70 characters.
  • Character position is 1 based (not 0 based as usual in calculations).

Examples

  • "{{str find long|abc bde|a}}" gives "1" [1]
  • "{{str find long|abc bde|b}}" gives "2" [2]
  • "{{str find long|abc bde|c}}" gives "3" [3]
  • "{{str find long|abc bde| }}" gives "4" [4]
  • "{{str find long|abc bde|d}}" gives "6" [5]
  • "{{str find long|abc bde|e}}" gives "7" [6]
  • "{{str find long|abc bde|f}}" gives "-1" [7]

Applications

See also

Easy to use and efficient string length comparison templates:

  • {{str ≥ len}} – To check if a string is "longer or equally long" vs. "shorter" than a given length.
  • {{str ≤ len}} – To check if a string is "shorter or equally long" vs. "longer" than a given length.
  • {{str ≠ len}} – To check if a string is "not equal" vs. "equal" to a given length.
  • {{str ≤ ≥ len}} – To check all three of "shorter", "equal" and "longer" at the same time.

Much less efficient string length template:

  • {{str len}} – Takes a string as parameter and returns its length. Can count up to 500 in length.

Technical stuff:

Advertisement