• होम
  • अट्रेंडम
  • आसपास
  • खाता में प्रवेश
  • सेटिंग्स
Donate Now If Wikipedia is useful to you, please give today.
  • विकिपीडिया के बारे में
  • नामंजूरी
विकिपीडिया

टेम्पलेट:Str left

  • भाषा
  • धियानसूची में डालीं
  • संपादन करीं
Template documentation[view] [edit] [history] [purge]
WarningThis template is used on 990,000+ pages.
To avoid large-scale disruption and unnecessary server load, any changes to it should first be tested in its /sandbox or /testcases subpages or in your own user subpage. The tested changes can then be added to this page in a single edit. Please consider discussing any changes on the talk page before implementing them.

बिसयसूची

  • 1 Usage
  • 2 Limitations
  • 3 उदाहरण
    • 3.1 Examples of limitations
  • 4 Template data
  • 5 इहो देखल जाय

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).

उदाहरण

संपादन करीं
  • {{ 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 is not safe with character entity references found in its string parameter :

  • {{ Str left | a&nbsp;c | 3 }} → a&n
    This should display "a c", but the named character entity was partially 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 partially 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.

The following example shows that the presence of some wiki markup that should be transparent and ignored, does not allow this template to work as expected (the nowiki section is replaced by a unique index string in the effective runtime value of the parameter; this unique (43-bytes long) string starts by a control character (which will be finally filtered out from the generated HTML page if it remains in the result of this template), followed by "UNIQ" and some unique sequence and terminated by "QINU" and a final control character; it is partially visible below, because the unique string is not complete after truncation, and then cannot be eliminated from the output in the first two lines):

  • {{ Str left | a<nowiki/>bc | 3 }} → abc
    It effectively returns 3 bytes, but the \x07 (BELL) control in the second position is stripped out when generating the HTML displayed here.
  • {{ Str left | a<nowiki/>bc | 43 }} → abcabcabcabcabcabcabcabcabcabcabcabcabcabca
    It effectively returns 43 bytes, but the \x07 (BELL) control in the second position is stripped out when generating the HTML displayed here, and the final \x07 was truncated
  • {{ Str left | a<nowiki/>bc | 44 }} → abcabcabcabcabcabcabcabcabcabcabcabcabcabcab
    It effectively returns 44 bytes, but the complete 43-bytes sequence is filtered out from the output wiki code when generating the final HTML, so there just remains the first leading "a" character .
  • {{ Str left | a<nowiki/>bc | 45 }} → abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc

On the opposite, the HTML comments, and the "noinclude", "includeonly" and "onlyinclude" wiki markup tags are safe, 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 documentation for this template used by VisualEditor and other tools.

TemplateData for Str left

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

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
String1

The string to be trimmed and counted

Stringrequired
Count2

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

Numberrequired

इहो देखल जाय

संपादन करीं
  • Bugzilla:22555 (need for correcting padleft/padright functions and to provide better string-handling parser functions)


  • दे
  • बा
  • सं
String-handling templates
Trimming
By counting
{{str mid}} To return a substring specified by position and length.
{{trunc}} To trim down to a specified number of characters.
{{str left}} To trim down to a specified number of characters or duplicate the string to a specified number.
{{str crop}} To crop a specified number of characters off the end.
{{chop head and tail}} To crop a specified number of characters off the beginning and end.
{{str right}} To trim the first specified number of characters.
{{str rightc}} To return a number of characters from the end, returns a parameter if the string is empty.
{{str rightmost}} To trim down to the last specified number of characters.
{{str sub old}} To trim down to a specified number, starting at a given number from the left.
{{str sub new}} Select a substr based on starting and ending index.
{{str index}} Returns a given character from a string, but not accented letters.
By checking
{{trim}} To trim any leading or trailing whitespace
{{str letter/trim}} To trim down to the beginning letters.
{{str number/trim}} To trim down to the beginning numbers.
{{trim brackets}} To trim any leading or trailing square brackets.
{{first word}} To trim down to the first space.
{{remove first word}} To remove anything before the first space.
{{last word}} To trim down from the last space.
{{remove last word}} To remove anything after the last space.
Dedicated
{{delink}} Removes wikilink brackets (wikicode).
{{remove file prefix}} Removes "File:" (or "Image:") from filenames.
{{PAGENAMEBASE}} To trim off any parenthesis text at the end of a string (disambiguation).
{{title disambig text}} Returns text in parenthesis at the end of a string (disambiguation).
{{WikiProjectbasename}} Removes "WikiProject" from a pagename.
{{remove unranked}} Removes the string "unranked_" from the left of a string (taxonomy).
{{ship prefix}} Returns the length of a ship's name prefix, if listed (ship names).
{{title year}} Returns the 4-digit year from a pagename, if any.
Insertion, replacement and length
{{strloc insert}} Inserts a string at character location strloc, or appends if strloc<=0.
{{loop}} Repeat character string a specified number of times.
{{repeat}} Repeat a 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.
{{str len}} Returns a string's length.
{{iflenge}} [if len]gth [g]reater than or [e]qual to.
{{str ≥ len}} To check if a string is "longer or equally long" or "shorter" than a given length.
{{str ≤ len}} To check if a string is "shorter or equally long" or "longer" than a given length.
{{str ≠ len}} To check if a string is "not equal" or "equal" to a given length.
{{str ≤ ≥ len}} To check if a string is "shorter", "equal", or "longer" than a given length.
Analysis and technical
{{str endswith}} To check if a string ends with a given string.
{{str find}}
{{strfind short}}
Returns the numerical location of a given string in a string.
{{str find0}} Zero-based substring search.
{{str sub find}} Searches a substring in a string at the given offset.
{{str letter}} Returns the number of letters that begin a string.
{{str number}} Returns the number of numbers that begin a string.
{{str gtr str}} Compares two strings for alphabetical order, and returns a value accordingly.
{{ASCII code}} Returns the ASCII value of a single character.
   
  Module:String
...Magic words
About {{padleft:|}}. ...ParserFunctions
About {{#titleparts:|}}, {{#expr:|}}, {{#ifeq:|}}, etc.
  • Category:String manipulation templates
  • m:Category:String templates
  • commons:Category:String manipulation templates
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://bh.wikipedia.org/w/index.php?title=टेम्पलेट:Str_left&oldid=489291" से लिहल गइल
Last edited on 29 अगस्त 2017, at 12:28

Languages

    • Аԥсшәа
    • Afrikaans
    • Alemannisch
    • Алтай тил
    • Obolo
    • العربية
    • الدارجة
    • অসমীয়া
    • Asturianu
    • Авар
    • Azərbaycanca
    • تۆرکجه
    • Башҡортса
    • Basa Bali
    • Boarisch
    • Batak Toba
    • Bajau Sama
    • Беларуская
    • Беларуская (тарашкевіца)
    • Български
    • Banjar
    • বাংলা
    • Bosanski
    • Буряад
    • Català
    • 閩東語 / Mìng-dĕ̤ng-ngṳ̄
    • Нохчийн
    • کوردی
    • Corsu
    • Čeština
    • Чӑвашла
    • Cymraeg
    • Dansk
    • Deutsch
    • Zazaki
    • Dolnoserbski
    • ཇོང་ཁ
    • Ελληνικά
    • English
    • Esperanto
    • Español
    • Eesti
    • Euskara
    • فارسی
    • Suomi
    • Føroyskt
    • Français
    • Gaeilge
    • Gagauz
    • Gàidhlig
    • Galego
    • 𐌲𐌿𐍄𐌹𐍃𐌺
    • ગુજરાતી
    • Gungbe
    • Gaelg
    • Hausa
    • 客家語 / Hak-kâ-ngî
    • עברית
    • हिन्दी
    • Hrvatski
    • Hornjoserbsce
    • Magyar
    • Հայերեն
    • Արեւմտահայերէն
    • Interlingua
    • Bahasa Indonesia
    • Igbo
    • Ilokano
    • ГӀалгӀай
    • Íslenska
    • Italiano
    • 日本語
    • Jawa
    • Qaraqalpaqsha
    • Taqbaylit
    • Kumoring
    • Қазақша
    • ភាសាខ្មែរ
    • 한국어
    • Kurdî
    • Kernowek
    • Latina
    • Lëtzebuergesch
    • Лакку
    • Лезги
    • Ladin
    • Lietuvių
    • Latviešu
    • Madhurâ
    • मैथिली
    • Basa Banyumasan
    • Мокшень
    • Malagasy
    • Олык марий
    • Māori
    • മലയാളം
    • Монгол
    • ဘာသာမန်
    • मराठी
    • Кырык мары
    • Bahasa Melayu
    • မြန်မာဘာသာ
    • Эрзянь
    • Plattdüütsch
    • नेपाली
    • नेपाल भाषा
    • Li Niha
    • Nederlands
    • Norsk nynorsk
    • Norsk bokmål
    • Sesotho sa Leboa
    • Chi-Chewa
    • Livvinkarjala
    • ଓଡ଼ିଆ
    • Ирон
    • ਪੰਜਾਬੀ
    • Pangasinan
    • Papiamentu
    • Pälzisch
    • पालि
    • پښتو
    • Português
    • Rumantsch
    • Ikirundi
    • Română
    • Руски
    • Русский
    • Русиньскый
    • संस्कृतम्
    • Саха тыла
    • Scots
    • سنڌي
    • Srpskohrvatski / српскохрватски
    • တႆး
    • සිංහල
    • Simple English
    • Slovenčina
    • Slovenščina
    • Anarâškielâ
    • Српски / srpski
    • Svenska
    • Sakizaya
    • தமிழ்
    • ತುಳು
    • ᥖᥭᥰ ᥖᥬᥲ ᥑᥨᥒᥰ
    • తెలుగు
    • Тоҷикӣ
    • ไทย
    • Tolışi
    • Tok Pisin
    • Türkçe
    • Татарча / tatarça
    • ChiTumbuka
    • Тыва дыл
    • Українська
    • اردو
    • Oʻzbekcha / ўзбекча
    • Vèneto
    • Tiếng Việt
    • Volapük
    • Winaray
    • 吴语
    • ייִדיש
    • 中文
    • 文言
    • 閩南語 / Bân-lâm-gú
    • 粵語
    • IsiZulu
    विकिपीडिया
    • Wikimedia Foundation
    • Powered by MediaWiki
    • एह पन्ना पर आखिरी बेर संपादन 29 अगस्त 2017 के 12:28 बजे भइल रहल।
    • सामग्री CC BY-SA 4.0 की तहत उपलब्ध बा जबले कि अलगा से बतावल न गइल होखे।
    • गोपनीयता नीति
    • विकिपीडिया के बारे में
    • नामंजूरी
    • Code of Conduct
    • डेवलपर लोग
    • आँकड़ा
    • कुकी इस्टेटमेंट
    • उपयोग के शर्त कुल
    • डेस्कटॉप