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

求助:使用正则表达式提取字符串参数及目标内容977-1071

Extracting 977-1071 from Your Text with Regex

Hey there! Let's sort out this regex problem and get you the exact string you need.

First, let's break down why your original regex /(Adm6000)([^\7]+)/ isn't working:

  • The [^\7] part is matching any character except the ASCII BEL control character (code 7)—not the number "7" in your text. That's a common mix-up with how regex character sets handle escape sequences.
  • Even if that part worked, your regex would capture everything after Adm6000 up to the first BEL character, which isn't what you're targeting.

The Correct Regex

Looking at your text structure: Adm6000/977-1071/047421CA414149E5CEC5—your target 977-1071 sits right between Adm6000/ and the next /.

Here are two reliable ways to capture it:

  1. Using a Capture Group (perfect if you need to extract just this specific part):

    /Adm6000\/([^\/]+)/
    
    • Adm6000\/: Matches the literal string Adm6000/ (we escape the / with \ because it acts as a regex delimiter).
    • ([^\/]+): Captures one or more characters that are not a /—this will exactly grab 977-1071.
  2. Using Positive Lookbehind (if you want to match the target directly without extra groups):

    /(?<=Adm6000\/)[^\/]+/
    
    • (?<=Adm6000\/): Checks that Adm6000/ comes right before the target (but doesn't include it in the final match).
    • [^\/]+: Again, matches all characters until the next /.

Testing It

If you run either regex against your text:

BAYARPLN ke 116160029354, SUKSES. Hrg: 84.822. SN: TGK IMUM M SAMIN/R1/450/MAR,APR/Rp.89222/Adm6000/977-1071/047421CA414149E5CEC5. Saldo: 7

Both will correctly pick out 977-1071.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 08:56:17