Action
Format Number
UPDATES
almost 2 years ago
String non-numeric characters before formatting.
Text selected text in the editor, convert it to a number, and replace with a formatted number string. (e.g. 1234567 becomes 1,234,567).
Demonstrates the use of Javascript number formatting.
Steps
-
script
let sel = editor.getSelectedText() sel = sel.replace(/[^\d.-]/g, '') // remove non-numerics let n = parseFloat(sel); if (!n) { console.log("Text selection must be number") context.cancel() } else { editor.setSelectedText(n.toLocaleString()) }
Options
-
After Success Default Notification Error Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.