• خانه
  • تصادفی
  • ورود
  • تنظیمات
  • دربارهٔ دانشنامه فقه معاصر
  • تکذیب‌نامه‌ها
دانشنامه فقه معاصر

الگو:Str left

  • زبان
  • پیگیری
  • نمایش مبدأ
Template documentation[view] [edit] [history] [purge]
هشداراین الگو in system messages، و در نزدیک به ۱٬۳۷۰٬۰۰۰ صفحه، یا نزدیک به ۲۴۵۷۸٪ از کل صفحه‌ها صفحه.
تغییر دادن آن می‌تواند به تغییر بی‌درنگ در رابط کاربری ویکی‌پدیا منجر شود.
به‌منظور جلوگیری از ایجاد اخلال و وارد شدن فشار به سرورها، هرگونه تغییر باید ابتدا در زیرصفحه‌های /تمرین یا /آزمایشی الگو، یا در زیرصفحهٔ کاربری خودتان آزمایش شود. تغییرات آزمایش‌شده را می‌توان در یک ویرایش به این صفحه افزود. لطفاً ابتدا در خصوص تغییرات مورد نظر در صفحهٔ بحث گفتگو کرده و سپس آن‌ها را پیاده‌سازی کنید.

فهرست

  • ۱ Usage
  • ۲ Limitations
  • ۳ Examples
    • ۳.۱ Examples of limitations
  • ۴ Template data
  • ۵ See also

Usage

{{Str left|<string>|<count>}}

Gives the resultant <count> of characters creating a substring of characters from the start of the trimmed string (i.e. the substring returned will have length <count>, exclusive of leading whitespace characters, which are trimmed first before <count> is invoked).

If <count> is invalid, empty or zero, an empty string is returned. If undefined, it defaults to 1.

Limitations

  • Length to 500: The maximum substring stops at 500 long, yet gives no error message. Only 500 characters can be extracted even if the <string> is longer.
  • Inexpensive (uses no other templates).

Examples

  • {{ Str left | Lorem ipsum dolor sit amet | 10 }} → Lorem ipsu
  • {{Str left|   Lorem ipsum dolor sit amet | 4 }} → Lore, (note leading spaces trimmed!)
  • {{ Str left | Lorem ipsum dolor sit amet | 1 }} → L
  • {{ Str left | Lorem ipsum dolor sit amet | 0 }} →
  • {{ Str left | Lorem ipsum dolor sit amet | }} →
  • {{ Str left | Lorem ipsum dolor sit amet }} → L
  • {{ Str left | Lorem ipsum dolor sit amet | 40 }} → Lorem ipsum dolor sit ametLorem ipsum do
  • {{ Str left | àçé | 2 }} → àç
    This example is demonstrating the safety of this template with the UTF-8 encoding (this should work now) :

Examples of limitations

All the limitations of use for this template and shown below are caused by the current implementation of the {{padleft:}} parser function used in this template, which does not filter its third parameter containing the characters used for padding a string to the specified length (it currently counts incorrectly the characters to extract from the padding string, and incorrectly measures its effective length; in addition this parameter is limited to 500 bytes).

The following examples are demonstrating that this template does not interpret character entity references as the character they represent. It treats them as multiple characters and can leave them truncated.

  • {{ Str left | a&nbsp;c | 3 }} → a&n
    The output "a c" may have been intended, but the named character entity was truncated, leaving no length available for the final "c".
  • {{ Str left | a&#66;c | 3 }} → a&#
    This should display "abc", but the named character entity was truncated, leaving no length available for the final "c".
  • {{ Str left | a c | 3 }} → a c
    The result is correct, as expected.
  • {{ Str left | a&#32;c | 3 }} → a&#
    This last example should be equivalent to the previous one, but it is not.

This template will erase nowiki tags without counting their length:

  • {{ Str left | a<nowiki/>bcd | 3 }} → abc
    Returns three characters as expected
  • {{ Str left | a<nowiki>E</nowiki>bcd | 3 }} → abc
    Returns three characters, but not aEb as might have been expected.
  • {{ Str left | a<nowiki/>bc | 10 }} → abcabcabca
    Returns 10 characters as expected.

HTML comments, and the "noinclude", "includeonly" and "onlyinclude" wiki markup tags are also ignored, because they are preprocessed in template parameters, before including it and substituting parameters:

  • {{ Str left | a<noinclude/>bc | 3 }} → abc
  • {{ Str left | a<!-- comment -->bc | 3 }} → abc

Note also that the specified length will cause the input string to be padded by repeating it, if this length is larger than the input string length:

  • {{ Str left | Abc. | 10 }} → Abc.Abc.Ab

Template data

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. Click here to see a monthly parameter usage report for this template based on this TemplateData.

TemplateData for Str left

A template to give the <count> substring of characters from the start of the trimmed string

پارامترهای الگو

پارامترتوضیحاتنوعوضعیت
String1

The string to be trimmed and counted

رشتهضروری
Count2

Gives the <count> substring of characters from the start of the trimmed string

شمارهضروری

See also

  • Bugzilla:22555 (historical; need for correcting padleft/padright functions and to provide better string-handling parser functions)
صفحه الگو:فهرست ساده/styles.css محتوایی ندارد.
  • ن
  • ب
  • و
String-handling templates (help page)
Substring (select chunk of string by its position)
{{#invoke:string|sub}}
{{str sub new}}
Select a substring based on starting and ending index counted in either direction.
{{str left}} Keep the first N characters of a string, or duplicate it to N characters.
{{str crop}} Return all but the last N characters of a string.
{{str index}} Return the N-th character of a string.
{{str right}} Return substring starting at N-th character to end of string.
{{str rightc}} Return the last N characters of a string; or a given value if empty.
{{str sub old}} Return substring of given length starting at N-th character.
Trimming (select/remove chunk of string by character type)
{{trim}} Trim any leading or trailing whitespace
{{str letter/trim}} Trim down to the beginning letters.
{{str number/trim}} Trim down to the beginning numbers.
{{trim brackets}} Trim any leading or trailing square brackets.
{{trim quotes}} Trim leading or trailing matching quotes.
{{trim leading}} Trim up to six instances of specified <prefix>.
{{string split}} Extract a short string from a long string.
{{first word}} Trim down to the first space.
{{remove first word}} Remove anything before the first space.
{{last word}} Trim down from the last space.
{{remove last word}} Remove anything after the last space.
Select/remove specific item from string
{{delink}}, {{trim brackets}} Removes wikilink brackets (wikicode); all or outer only.
{{remove file prefix}} Removes "File:" (or "Image:") from filenames.
{{PAGENAMEBASE}} Trim off any parenthesis text at the end of a string (disambiguation).
{{title disambig text}} Returns text in parentheses at the end of a string (disambiguation).
{{WikiProjectbasename}} Removes "WikiProject" from a pagename.
{{ship prefix}} Returns the length of a ship's name prefix, if listed (ship names).
{{title year}} Returns the 3-or-4-digit year from a pagename, if any.
{{title decade}} Returns the 4-digit decade (e.g. "1740s") from a pagename, if any.
{{title number}} Returns any number from a pagename.
Insertion, replacement and length
{{loop}} Repeat character string a specified number of times.
{{replace}} Returns the string, after replacing all occurrences of a specified string with another string.
{{str rep}} Returns the string, after replacing the first occurrence of a specified string with another string.
{{digits}} Returns the string, after removing all characters that are not digits 0–9
{{Plain text}}, {{Nowiki}} Strips wikicode from a string.
{{str len}} Returns a string's length.
{{str ≥ len}} Check if a string is "longer or equally long" or "shorter" than a given length.
{{str ≤ len}} Check if a string is "shorter or equally long" or "longer" than a given length.
{{str ≠ len}} Check if a string is "not equal" or "equal" to a given length.
Analysis and searching
{{#invoke:string2|startswith}}
{{str endswith}}
Check if a string starts or ends with a given string.
{{str find}}, {{strfind short}} Returns the numerical location of a given string in a string.
{{in string}} Returns optional string when given string is not found
{{str count}} Count the number of occurrences of a pattern within a string.
{{a or an}} Takes a noun and produces the appropriate indefinite article, based on whether the first letter is a vowel.
{{Isnumeric}} Returns number when true, blank when not numeric.
{{str letter}} Returns the number of letters that begin a string.
{{str number}} Returns the number of numbers that begin a string.
Modules and built-in functions
  • Module:String, Module:String2, Module:Ustring, Module:Text: modules that together contain most necessary string functions.
  • Magic words: About {{padleft:|}}, {{lc:|}}, {{formatnum:|}} etc.
  • ParserFunctions: About {{#titleparts:|}}, {{#expr:|}}, {{#ifeq:|}}, etc.
  • Category:String manipulation templates
    • Commons
    • MediaWiki
    • Meta-Wiki
    • Wikidata
  • The above documentation is transcluded from الگو:Str left/doc. (edit | history)
    Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
    Add categories to the /doc subpage. Subpages of this template.
    برگرفته از «https://ency.feqhemoaser.com/fa/index.php?title=الگو:Str_left&oldid=9216»
    آخرین‌بار در ‏۳ مارس ۲۰۲۲، ‏۰۹:۵۴ ویرایش شده است

    زبان‌ها

      این صفحه به زبان‌های دیگر در دسترس نیست.

      دانشنامه فقه معاصر
      • این صفحه آخرین‌بار در ‏۳ مارس ۲۰۲۲ ساعت ‏۰۹:۵۴ ویرایش شده است.
      • محتوایات تحت اجازه‌نامهٔ Creative Commons Attribution-NonCommercial-ShareAlike هستند مگر اینکه خلافش ذکر شده باشد.
      • سیاست حفظ حریم خصوصی
      • دربارهٔ دانشنامه فقه معاصر
      • تکذیب‌نامه‌ها
      • نمای رایانه