Template:Strloc insert/doc

The string-inserter Template:Strloc insert inserts a text string into another string at a specified location, or adds it at the end.

Usage

{{Strloc insert|<string1>|strloc=<n>|<string2>}}

Returns string1 with string2 inserted at location strloc=n, where n=1 denotes the start of the string (prepending). If strloc <= 0 then string2 is appended at the end of string1. The parameter strloc can be a math formula, such as: strloc={{{len}}}-2, or strloc=abs(-2*5)+6.

Examples

The following show various uses:

  • {{Strloc insert|abcdef|strloc=4|ZZZ}} → abcZZZdef
  • {{Strloc insert|123456|strloc=1|++}} → ++123456
  • {{Strloc insert|Abcd|strloc=0 |EFG}} → AbcdEFG
  • {{Strloc insert|<i>Out of Africa (film)|strloc=17|</i>}} → Out of Africa (film)
  • {{Strloc insert|[[Out of Africa (film)|<i>Out of Africa (film)]]|strloc=17+20|</i>}} → Out of Africa (film)
Note, the example wikilinking "Out of Africa" inserted "</i>" as end-italics,
but with strloc=17+20 to skip farther in the "[[ ]]" wikilink string.
  • {{Strloc insert|<i>Cosmos (book)|strloc={{strfind_short|Cosmos (book)|(|1}}|</i>}} → Cosmos (book)
In the example with "Cosmos (book)" the number for strloc was set by finding "(" in the
title. If there had been no "(" then the result would append "</i>" at the end of the title.

Limitations

The text at the end (after string2) is subject to the limitations of Template:Str right. Spaces around the inserted string are limited to 1 space, before or after:

Spaces beyond the inserted string might be encoded as "&#32;" rather than being real spaces.

  • {{Strloc insert}} - Inserts a string at character location strloc, or appends if strloc<=0.
  • {{Strloc prefix}} - Extracts string prefix up to location strloc, or whole string if strloc<=0.


Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.