求正则表达式:在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 (likeA.,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
- Open your document and hit
Ctrl+Hto open the Replace dialog. - Check the Regular expression box (ensure the engine is set to Perl-compatible — this is the default in newer versions).
- Paste the search regex into the Find what field, and the replacement string into Replace with.
- Click Replace All to apply changes to the entire document.
PowerGREP
- Create a new search/replace action.
- Under the Search tab, select Regular expression and pick the Perl-compatible engine.
- Paste the search regex into the search field.
- Switch to the Replace tab and paste the replacement string.
- 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

