Difference between revisions of "Template:Str sub long/doc"

From FamilySearch Wiki
Jump to navigation Jump to search
(Created page with "{{Documentation subpage}} <!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --> === Usage === <code><nowiki>{{</nowiki>{{PAGENAME}} |''text''|''start''|''leng...")
 
m (remove { from templates)
Line 7: Line 7:
 
''start'' + ''length'' must be less than 100.  The template operates on an extended character set.
 
''start'' + ''length'' must be less than 100.  The template operates on an extended character set.
  
:{{Str character set documentation}}, plus accented letters and other [[diacritics]].
+
:Str character set documentation, plus accented letters and other [[diacritics]].
  
 
=== Limitations ===
 
=== Limitations ===
Line 20: Line 20:
 
* {{Tl|Str sub}}
 
* {{Tl|Str sub}}
 
* {{Tl|Str sub long}} - allows 100 characters, but not ":" or ";" or "*"
 
* {{Tl|Str sub long}} - allows 100 characters, but not ":" or ";" or "*"
* {{Tl|Str sub/any}} &nbsp;- allows any character, such as ":" or ";" or "*" or "#"
+
* Tl|Str sub/any &nbsp;- allows any character, such as ":" or ";" or "*" or "#"
* {{String templates see also}}
+
* String templates see also
  
 
<includeonly>
 
<includeonly>

Revision as of 14:03, 8 January 2019

Usage[edit source]

{{Str sub long/doc |text|start|length}} = Substring of text starting at start and containing length characters. Base 0: the first character is numbered 0, and so on, e.g. {{str sub long|20090624130510|8|2}} returns the 2 characters starting at the 9th, i.e. "13"

start + length must be less than 100. The template operates on an extended character set.

Str character set documentation, plus accented letters and other diacritics.

Limitations[edit source]

A string is limited to 500 total characters, but the substring can only span the first 100 characters. The presence of certain characters in the input may cause unexpected results, so {{Str_sub/any}} should be used to handle any possible character. Otherwise, there can be problems with some special characters. For example, {{Str sub long|abc%def|2|3}} → c%d works as desired, whereas if the output string contains any of :;*# the results are not as desired:
{{Str sub/any|abc:def|2|3}}Template:Str sub/any
{{Str sub long|abc:def|2|3}} → c

d

{{Str sub long|abc;def|2|3}} → c

d

{{Str sub long|abc*def|2|3}} → c

  • d

{{Str sub long|abc#def|2|3}} → c

  1. d

See also[edit source]

  • {{Str sub}}
  • {{Str sub long}} - allows 100 characters, but not ":" or ";" or "*"
  • Tl|Str sub/any  - allows any character, such as ":" or ";" or "*" or "#"
  • String templates see also