Skip to content

Instantly share code, notes, and snippets.

@juandbc
Last active February 21, 2025 18:45
Show Gist options
  • Save juandbc/d1d9fccd12ba8880873de4be02896d17 to your computer and use it in GitHub Desktop.
Save juandbc/d1d9fccd12ba8880873de4be02896d17 to your computer and use it in GitHub Desktop.
Expresiones regulares útiles

Notas de RegExp útiles

Buscar número con o sin formato de miles

(?:^(?:[0-9]{1,3})(?:(?:\.{0,1}(?:[0-9]{3}))\b)+)$|(^[0-9]+$)

Obtener número de un texto (JS)

let matches = string.match(/(^\d+|^\-\d+)/gi);

Aplicar formato moneda (JS)

string.replace(/\d(?=(\d{3})+\.)/g, '$&,');

Es número (JS)

return /^-?[0-9]+(\.\d+)?$/g.test(string);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment