Number or text?
FreeLogicTells whether typed text is a number (`42`, `-3.5`) or plain text, and converts it.
Text from a form is always a string, so Type Of would say string even for 42. A regular expression decides what counts as a number (here: an optional minus, digits and an optional decimal part), then To Number converts it. On its own To Number would accept the empty text (as 0), 1e3 and 0x1F.
Shows: Trim, Regex Match, Branch, To Number.
Add it to your logic, then add a Call Function step in any logic and pick Number or text. It belongs to no system, so every system can use it. Or download the TypeScript and call it from your own code.
- No matches
- No matches
Arrow keys: next or previous step in flow order. Alt with arrows: nearest step in that direction. Enter: open. Shift F10: more actions.
| Passed | Example | Input | Output |
|---|---|---|---|
| A whole number with spaces | {"text":" 42 "} | {"kind":"number","value":42} | |
| A negative decimal | {"text":"-3.5"} | {"kind":"number","value":-3.5} | |
| Text | {"text":"12abc"} | {"kind":"text","value":"12abc"} | |
| Empty | {"text":""} | {"kind":"text","value":""} |
