You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用JavaScript正则提取ParseHub爬取的货币数字(去除$及千分位点)

Got it, let's fix that regex issue for your ParseHub scraping task!

First, let's break down why your current regex ([-0-9/|,]+) isn't working for $1.000,00: it only matches continuous characters from the set [-0-9/|,]—the thousand-separator dot . isn't included here, so the match stops as soon as it hits that dot, leaving you with just 1.

Here are two straightforward solutions tailored to your needs:

Solution 1: Capture first, then clean up the dots

Use this regex to capture everything after the dollar sign (including dots and commas):

^\$([\d.,]+)$
  • ^\$ targets the leading dollar sign (we don't want to capture this part)
  • ([\d.,]+) captures the core value: all digits, thousand-separator dots, and the decimal comma

Then, in ParseHub, take the captured group (e.g., 1.000,00) and run a string replacement to remove all dots:

  • Replace . with an empty string
  • This turns 1.000,00 → 1000,00, 800,64 stays 800,64, and 100,00 stays 100,00

If you need to handle negative values like -$1.000,00, adjust the regex to:

^-?\$([\d.,]+)$

Solution 2: One-step regex replacement (if ParseHub supports it)

If ParseHub lets you use a regex to replace parts of the string directly, use this find-and-replace pair:

  • Find regex: ^\$|\.
  • Replace with: Empty string

This will strip out both the leading dollar sign and all thousand-separator dots in one go, giving you exactly the format you need right away.

Both methods work for values with multiple thousand-separators too—like $1.234.567,89 will become 1234567,89 perfectly.

内容的提问来源于stack exchange,提问作者PmF111

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:27:17