Get the number at a specified position in a number

How to get the number at a specified position in the Anqi CMS template?

get_digitThe filter can obtain the digit at a specified position within a number, with the position counted from the end of the number, starting from 1.If the position to be obtained does not exist, return the entire number.If the original number is a number, the obtained result is the ASCII value of the character at that position minus 48 to get the number.

Usage Instructions

get_digitHow to use the filter:

{{ obj|get_digit:number }}

For example, if you need to get1234567890To get the last third digit, you can write it like this:

{{ 1234567890|get_digit:3 }}
# 显示结果
8

Here is an example demonstration

{{ 1234567890|get_digit:0 }}
{{ 1234567890|get_digit }}
{{ 1234567890|get_digit:2 }}
{{ 1234567890|get_digit:"4" }}
{{ 1234567890|get_digit:10 }}
{{ 1234567890|get_digit:15 }}
{{ "anqicms"|get_digit:2 }}
{{ "ANQICMS"|get_digit:2 }}
{{ "安企内容管理系统"|get_digit:2 }}
# 显示结果
1234567890
1234567890
9
7
1
1234567890
61
29
139