How to convert mobile phone keypad letters to numbers in Anqi CMS template?
phone2numeric
The filter can convert letters on the phone number keypad to numbers.
The conversion relationship is:
{
"a": "2", "b": "2", "c": "2", "d": "3", "e": "3", "f": "3", "g": "4", "h": "4", "i": "4", "j": "5", "k": "5",
"l": "5", "m": "6", "n": "6", "o": "6", "p": "7", "q": "7", "r": "7", "s": "7", "t": "8", "u": "8", "v": "8",
"w": "9", "x": "9", "y": "9", "z": "9"
}
Usage Instructions
phone2numeric
How to use the filter:
{{ obj|phone2numeric }}
For example, if you need to split999-PONGO2
If you want to convert to numbers, it can be written like this:
{{ "999-PONGO2"|phone2numeric }}
# 显示结果
999-766462
Here is an example demonstration
{{ "999-PONGO2"|phone2numeric }}
# 显示结果
999-766462