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

116
Vistas
regular expression to match start character of string + space then digits like currency

How do I test a string that contains a character at the start then a space and whatever comes after that which could be an integer or float?

Example:

'$ 15'

'$ 15.95'

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

0

/\$\s[\d]*\.[\d]{2}|\$\s[\d]*[^.]/gm

$space(endless digits until)period and exactly-2digits
|OR
$space(endless digits-no periods)

const rgx = /\$\s[\d]*\.[\d]{2}|\$\s[\d]*[^.]/gm;

const str = `\$ 15.95 \$ 5 \$ 2.00
\$ 6.90 \$ 1101`;

let matches = [...str.matchAll(rgx)].flat();

console.log(matches);

about 4 years ago · Juan Pablo Isaza Denunciar

0

I think it could help you: ^\$ [+-]?[0-9]{1,}(\.[0-9]{1,}){0,1}, you can test it here: https://regex101.com/

  • ^\$: start with a character
  • then add a space
  • [+-]? then add optional signs
  • [0-9]{1,} then add at less one digit
  • (\.[0-9]{1,}){0,1} then add a dot and at less one digit
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use below regular expression :

. \d+(?:.\d+)?

Test it here : https://regex101.com/r/1oqIO8/1

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