Jump to content

Template:hexnum

From Wiktionary, the free dictionary

Usage

[edit]

Used for testing for hexadecimal numbers. Returns 1 if the condition is satisfied, an empty string otherwise:

Wikitext Result
{{#if:{{hexnum|FFFFFF|digits=6}}
  | Yes, hex!
  | Nope, something else.
}}
Yes, hex!

Parameters

[edit]
|1=
Hexadecimal number.
|allow_empty=
Return 1 if |1= is empty.
|digits=
Fail if |1= is given but does not have this number of digits. The template will generate an error if this parameter is supplied but is not a decimal number.

Examples using the {{#if:}} parser function

[edit]
Wikitext Result
{{#if:{{hexnum|ABCDEF|digits=6}}
  | This is a hexadecimal number!
  | This is not a hexadecimal number!
}}
This is a hexdecimal number!
{{#if:{{hexnum|Hello, world!|digits=6}}
  | This is a hexadecimal number!
  | This is not a hexadecimal number!
}}
This is not a hexadecimal number!