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

求正则表达式:在EditPad Pro/PowerGREP中为无标点句末添加问号

Solution for Adding Question Marks to Incomplete Sentences in EditPad Pro/PowerGREP

Let’s break down how to fix this with a tailored regex that works seamlessly in your chosen tools:

Step 1: The Regex Search Pattern

Here’s the regex you’ll use to target the incomplete sentence endings:

([^.!?])\s*(?=[A-Z]\.)

What each part does:

  • ([^.!?]): Captures any character that isn’t a period, question mark, or exclamation mark — this is the final character of your unfinished question stem.
  • \s*: Matches zero or more spaces between the stem’s end and the start of the options (handles cases where there’s no space or extra spacing).
  • (?=[A-Z]\.): A positive lookahead that ensures the next characters are an uppercase letter followed by a period (like A., B. — the start of your answer options).

Step 2: The Replacement String

Use this to insert the missing question mark:

$1?

This takes the captured character from the first group and appends a question mark right after it, preserving any existing spaces between the stem and options.

Step 3: Tool-Specific Setup

EditPad Pro

  1. Open your document and hit Ctrl+H to open the Replace dialog.
  2. Check the Regular expression box (ensure the engine is set to Perl-compatible — this is the default in newer versions).
  3. Paste the search regex into the Find what field, and the replacement string into Replace with.
  4. Click Replace All to apply changes to the entire document.

PowerGREP

  1. Create a new search/replace action.
  2. Under the Search tab, select Regular expression and pick the Perl-compatible engine.
  3. Paste the search regex into the search field.
  4. Switch to the Replace tab and paste the replacement string.
  5. Select your target files and run the action.

Step 4: Verify with Your Example

Original text:

扁平苔藓最常发生于A.颊黏膜。B.舌。C.口底。D.牙龈。
在缺乏“Hanks balanced salt solution”时,转运离体组织的最适宜介质是A.唾液。B.牛奶。C.生理盐水。D.自来水。
以下哪项是65岁克罗恩病患者出现骨质疏松、青光眼、高血压和消化性溃疡的最可能原因A.未控制的糖尿病。B.全身糖皮质激素治疗。C.慢性肾衰竭。D.长期NSAID治疗。E.吸收不良综合征。

After running the regex replace, you’ll get your desired result exactly:

扁平苔藓最常发生于?A.颊黏膜。B.舌。C.口底。D.牙龈。
在缺乏“Hanks balanced salt solution”时,转运离体组织的最适宜介质是?A.唾液。B.牛奶。C.生理盐水。D.自来水。
以下哪项是65岁克罗恩病患者出现骨质疏松、青光眼、高血压和消化性溃疡的最可能原因?A.未控制的糖尿病。B.全身糖皮质激素治疗。C.慢性肾衰竭。D.长期NSAID治疗。E.吸收不良综合征。

This regex handles edge cases like quoted text in the question stem and varying spacing, so it’ll work reliably across both tools.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 07:08:59