{{
editprotected}}
This template is protected in a broken state as it returns characters in the range start − 1 → start + length
(which means it actually returns length + 1 characters, ending in the right spot but starting one step early):
{{str sub|0123456789ABCDEF|6|3}} == 678
The output "5678" is incorrect as the "5" should not be part of it.
See Comparison of programming languages (string functions)#substring. This does not match the syntax of any known language. Please fix. — CharlotteWebb 03:04, 14 June 2009 (UTC)
Like I did with {{ Str sub long}}, this template should use "|nocategory={{{nocategory|}}}" to allow example pages that generate errors to mark those as intentional. That way these pages do not show up on Category:Pages_with_incorrect_formatting_templates_use. Thanks! — SkyLined ( talk) 10:58, 4 November 2009 (UTC)
I think that the second and third lines of this code are never reached. In the first line it checks whether {{{2|0}}} = 0, so the condition {{{2|0}}} < 1 is never true. In theory, {{{2|0}}} < 1 could also include negative numbers, but as the template doesn't handle a negative start parameter anyway, {{{2|0}}} < 1 appears to be the same as {{{2|0}}} = 0. Can you check this? -- Entlinkt ( talk) 15:24, 18 December 2009 (UTC)
This template behaves quite similar to the #sub parser function for start ≥ 0 and length > 0, but differently in the length = 0 border case. The template returns an empty string, while #sub would return the entire rest of the string. Examples:
Should this be aligned? Effectively, length = 0 would result in the same as Template:Str right, similarly to start = 0 being the same as Template:Str left. -- Entlinkt ( talk) 15:24, 18 December 2009 (UTC)
Be aware that the result does not contain true space characters. Note the behaviour of the following:
Any template which relies on finding spaces in the result from {{ Str sub}} (or alternative versions) will not produce the right result. Peter coxhead ( talk) 09:54, 15 December 2011 (UTC)
![]() | This
edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please use the new lua invoke command to greatly reduce the size and complexity of this template -- it'll greatly reduce the burden on the backend servers. Here's the code that you can use, copy/paste format:
{{{{{|safesubst:}}}#invoke:String|sub|s={{{s}}}|i={{{i}}}|j={{{j}}}}}<noinclude> |
{{documentation}} |
<!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> |
Try it out for yourself, {{invoke:String|sub|s=ThisStringHere|i=5|j=11}} will return String. Thanks, Banaticus ( talk) 00:30, 21 February 2013 (UTC)
{{#invoke:String|sub|s=ThisStringHere|i=4|j=6}}
→ sSt
A discussion is taking place to address the redirect
Template:Str sub old/any. The discussion will occur at
Wikipedia:Redirects for discussion/Log/2021 April 26#Template:Str sub old/any until a consensus is reached, and readers of this page are welcome to contribute to the discussion.
User:GKFX
talk
11:32, 26 April 2021 (UTC)
A discussion is taking place to address the redirect
Template:Substr quick. The discussion will occur at
Wikipedia:Redirects for discussion/Log/2021 April 26#Template:Substr quick until a consensus is reached, and readers of this page are welcome to contribute to the discussion.
User:GKFX
talk
11:36, 26 April 2021 (UTC)
{{
editprotected}}
This template is protected in a broken state as it returns characters in the range start − 1 → start + length
(which means it actually returns length + 1 characters, ending in the right spot but starting one step early):
{{str sub|0123456789ABCDEF|6|3}} == 678
The output "5678" is incorrect as the "5" should not be part of it.
See Comparison of programming languages (string functions)#substring. This does not match the syntax of any known language. Please fix. — CharlotteWebb 03:04, 14 June 2009 (UTC)
Like I did with {{ Str sub long}}, this template should use "|nocategory={{{nocategory|}}}" to allow example pages that generate errors to mark those as intentional. That way these pages do not show up on Category:Pages_with_incorrect_formatting_templates_use. Thanks! — SkyLined ( talk) 10:58, 4 November 2009 (UTC)
I think that the second and third lines of this code are never reached. In the first line it checks whether {{{2|0}}} = 0, so the condition {{{2|0}}} < 1 is never true. In theory, {{{2|0}}} < 1 could also include negative numbers, but as the template doesn't handle a negative start parameter anyway, {{{2|0}}} < 1 appears to be the same as {{{2|0}}} = 0. Can you check this? -- Entlinkt ( talk) 15:24, 18 December 2009 (UTC)
This template behaves quite similar to the #sub parser function for start ≥ 0 and length > 0, but differently in the length = 0 border case. The template returns an empty string, while #sub would return the entire rest of the string. Examples:
Should this be aligned? Effectively, length = 0 would result in the same as Template:Str right, similarly to start = 0 being the same as Template:Str left. -- Entlinkt ( talk) 15:24, 18 December 2009 (UTC)
Be aware that the result does not contain true space characters. Note the behaviour of the following:
Any template which relies on finding spaces in the result from {{ Str sub}} (or alternative versions) will not produce the right result. Peter coxhead ( talk) 09:54, 15 December 2011 (UTC)
![]() | This
edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please use the new lua invoke command to greatly reduce the size and complexity of this template -- it'll greatly reduce the burden on the backend servers. Here's the code that you can use, copy/paste format:
{{{{{|safesubst:}}}#invoke:String|sub|s={{{s}}}|i={{{i}}}|j={{{j}}}}}<noinclude> |
{{documentation}} |
<!-- Add categories and interwikis to the /doc subpage, not here! --> </noinclude> |
Try it out for yourself, {{invoke:String|sub|s=ThisStringHere|i=5|j=11}} will return String. Thanks, Banaticus ( talk) 00:30, 21 February 2013 (UTC)
{{#invoke:String|sub|s=ThisStringHere|i=4|j=6}}
→ sSt
A discussion is taking place to address the redirect
Template:Str sub old/any. The discussion will occur at
Wikipedia:Redirects for discussion/Log/2021 April 26#Template:Str sub old/any until a consensus is reached, and readers of this page are welcome to contribute to the discussion.
User:GKFX
talk
11:32, 26 April 2021 (UTC)
A discussion is taking place to address the redirect
Template:Substr quick. The discussion will occur at
Wikipedia:Redirects for discussion/Log/2021 April 26#Template:Substr quick until a consensus is reached, and readers of this page are welcome to contribute to the discussion.
User:GKFX
talk
11:36, 26 April 2021 (UTC)