Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!