Template talk:Str left

I notice that this template trims the text before it gets the substring. I'm not sure how the string extensions do it, but I'd propose that we should try to kee

Trimming

I notice that this template trims the text before it gets the substring. I'm not sure how the string extensions do it, but I'd propose that we should try to keep the usages as similar as possible, in hopes that they might get installed at some point. --Amalthea 12:35, 31 March 2009 (UTC)Reply

Huh, I forgot that I left that here, but let me second myself! In the same spirit, we might want to merge {{Trunc}} into this template, and decide how the handle the extreme cases (invalid length, no length, negative length, length greater than the string length). Again, it's probably advisable to have a look how the string extensions do it, and keep it in line with them, for an easier transition.
From what I can tell I'm responsible for most usages of this template, through the {{image}} template. As far as I can tell we can still merge the two without the differences having an effect. Amalthea 22:51, 13 May 2009 (UTC)Reply
Str_left is not a built-in in the extension. Rather the equivalent would be {{#sub: text | 0 | length }} where #sub grabs arbitrary substrings and the zero tells it to start at the first character. Like all extension functions it will trim whitespace off text at both ends (this is actually parser behavior). If length is missing, not a number, or larger than the actual string length then it returns the whole string. If length is negative it returns abs(length) characters starting at the right end rather than the left. Dragons flight (talk) 23:47, 13 May 2009 (UTC)Reply

Str right

I guessing that the answer is no (because Template:Str right is currently red) but is there no possibly way to take characters from the end of a string? — Martin (MSGJ · talk) 22:58, 17 May 2009 (UTC)Reply

You can build it using {{str sub}} and {{str len}}, but that has rather severe limitations, and performs rather badly. Amalthea 23:09, 17 May 2009 (UTC)Reply
Oh nice. I just want to take off the first two characters. Template:Amg movie takes a parameter such as 1:356351 but the website has changed their links so now it just wants 356351. It would just be a temporary measure until we can get a bot to go round and change them all. — Martin (MSGJ · talk) 05:54, 18 May 2009 (UTC)Reply

Update "Examples of limitations"

MediaWiki's parser behavior has changed, and now some of the examples of limitations ouput does not match the description of that output. — SMcCandlish   Talk⇒ ɖ∘¿¤þ   Contrib. 22:59, 24 December 2012 (UTC)Reply

In particular, the whole first section is wrong. Basically, it just needs to say that HTML character entities are seen literally, not as the character they are meant to represent. {{Str left|a c |3}} → a&n, literally the first three chars of the string. " " looks like just another 6-character string to the function, not a single non-breaking space. —[AlanM1(talk)]— 01:53, 27 February 2013 (UTC)Reply

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.