Page MenuHomePhabricator

add {{#substr:}}, {{#head:}}, {{#tail:}}, {{#len:}} function
Closed, DeclinedPublic

Description

Author: anon.hui

Description:
{{ #substr: str | pos | len }} == {{ #mid: str | pos | len }}
{{ #substr: abcdef | 1 | 3 }} --> bcd
{{ #substr: abcdef | 1 }} --> bcdef
{{ #substr: abcdef | 0 | 3 }} --> abc

  • The "pos" and "len" can also be negative, and have the same behavior as php's substr()

{{ #head: str | len }} == {{ #left | len }} == {{ #substr: str | 0 | len }}
{{ #tail: str | len }} == {{ #right | len }} == {{ #substr: str | -len }}

If you need patch, I'm going to implement it.


Version: unspecified
Severity: enhancement

Details

Reference
bz16197

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 10:19 PM
bzimport set Reference to bz16197.
bzimport added a subscriber: Unknown Object (MLST).

anon.hui wrote:

Add one more common function,

  • {{ #len: str }} == {{ #strlen: str }} == {{ #length: str }}

mattj wrote:

strlin and substr already exist in StringFunctions extension. I'm not sure about head and tail, but they should be easily acheivable with that extension as well.

anon.hui wrote:

WONFIX: see comment #2