Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

105
Vistas
str.match - how to remove $ and show digital value only?

Here is my code value = str.match(/$(\d+)/);

For example 1: HK$999 Display Result = 999

For example 2: HK$1,999.20 Display result = 1 (I would not want this result)

How can show the example 2 = 1999

Thank you all ^_^

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This code should work fine first remove all the unnecessary comas from the string then select all the numbers before "."

var ragex = /(\d+)/g;

let str = "HR999";
str = "HK$1,999.20"
str = str.replace(/(,)/, '')

let res = str.match(ragex)[0];

the result will be at first index in the array

if you want numbers including.

use this ragex

var ragex = /\d+.\d+/g;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda