@studiovisual/brazilian-validator-js
Version:
A lightweight and efficient JavaScript library for validating Brazilian documents and phone numbers
14 lines (13 loc) • 498 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractDigits = extractDigits;
/**
* Extracts only the digits from the provided value.
* @param value The value to extract digits from. Accepts both strings and numbers.
* @returns A string containing only the extracted digits.
*/
function extractDigits(value) {
// Convert the value to a string and remove non-digit characters
const digits = String(value);
return digits.replace(/[^\d]/g, "");
}