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

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

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 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!