This page last changed on Oct 18, 2011 by jed.wheeler@involver.com.

Overview

Returns the digit of a number for the specified index.


Attributes

type required description
integer
true
The index of the digit you want, from right to left, starting at 0

Examples

Get the first digit of an integer

You can get the specified digit of an integer by passing the index of the digit from right to left.

{{ 12345 | get_digit:0 }}

Will give you:

5

Get the last digit of an integer

Similarly, you can get the last digit of an integer by passing the appropriate index:

{{ 12345 | get_digit:4 }}

Will give you:

1

It works with string representations of integers

You can filter on a string version of the integer:

{{ '12345' | get_digit:0 }}

Will give you:

0

Passing an invalid index

Passing an invalid index will return a blank output:

{{ 12345 | get_digit:10 }}

Will give you:



FAQ

No questions so far.


Related Topics

Document generated by Confluence on Feb 12, 2013 09:09