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

PCRE正则表达式:删除首个括号后的所有内容

Got it, let's solve this for your FME workflow. The key is to target the first complete parentheses pair (no matter what's inside it) and remove everything that comes after it.

Here's the PCRE regex you can use for replacement:

(?<=\([^)]+\)).*

How this works:

  • \( matches the opening parenthesis (escaped because parentheses have special meaning in regex)
  • [^)]+ grabs one or more characters that aren't a closing parenthesis—this ensures we capture whatever's inside the first set of parentheses, no matter what it is (like ROBERT_01, JIMBO_01, etc.)
  • \) matches the closing parenthesis
  • (?<=...) is a positive lookbehind assertion—this tells the regex to only match the content that comes right after that first complete parentheses pair
  • .* matches every character from that point to the end of the string (if you need to include newlines in the matched content, add the s modifier at the start: (?s)(?<=\([^)]+\)).*)

How to use this in FME:

  1. Add a Regular Expression Replacer transformer to your workspace
  2. Select the attribute containing your target string
  3. Paste the regex above into the "Regular Expression" field
  4. Leave the "Replacement Text" field blank (we want to delete the matched content)
  5. Double-check that the regex engine is set to PCRE (FME typically uses this by default, but it's worth confirming)

For example, if your input string is:

[TEXT1] TEXT EXAMPLE HERE (ROBERT_01) MORE TEXT HERE POSSIBLY SOME NUMBERS 9999 THEN TEXT (JIMBO_01)

After applying this regex, you'll get:

[TEXT1] TEXT EXAMPLE HERE (ROBERT_01)

If you prefer to extract the desired portion instead of replacing, you can use this regex in an Attribute Extractor or Regular Expression Evaluator:

^(.*?\([^)]+\))

Then capture the first group ($1)—this will give you everything from the start of the string up to and including the first closing parenthesis.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 09:53:56