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

Google Forms正则表达式扩展需求:在现有规则基础上添加自定义句子数量校验功能

Great question! Let's break down how to extend your existing Google Forms regex without breaking what's already working.

First, let's recap what your current regex does: it blocks unhelpful student phrases and ensures responses are at least 50 words (via the final pattern that matches responses with ≤49 words—since you're using "Doesn't Contain", this rejects short answers). To add your sentence requirements, we'll build on this by adding patterns that match responses failing your sentence rules, so those get rejected too.


Key Approach

Since we're using "Doesn't Contain" mode, we need to define patterns for responses that don't meet your sentence criteria. Any response matching these new patterns will be filtered out, leaving only valid answers that meet your word count, phrase, and sentence rules.


Option 1: Require at least 1 valid sentence

Add this pattern to the end of your existing regex (separated by |):

|^(?!.*?(?:^[A-Z].*?[.!?"]|\s+[A-Z].*?[.!?"])).*$

This matches responses with no valid sentences (per your definition: first sentence starts with an uppercase letter, subsequent sentences start with a space + uppercase letter, all end with .!?"). Rejecting these ensures every response has at least one valid sentence.


Option 2: Require at least 3 valid sentences

Add this pattern instead (adjust the number later to meet future needs):

|^(?!(?:.*?(?:^[A-Z].*?[.!?"]|\s+[A-Z].*?[.!?"])){3}).*$

This matches responses with fewer than 3 valid sentences. To require 5 sentences later, just change {3} to {5}—super easy to tweak.


Full Updated Regex (for at least 3 sentences)

Here's your complete regex combining all original rules with the 3-sentence requirement:

don't know|dont know|read about|video|i know|I know|do not remember| ah |ran out of time|i dont know|Blooket|blooket| assumption |chance|guess|studied|educated guess|remember reading|in the unit|annotations|I didn't know|guessed|asdf|sucks|I read it|i read it|I don't know| |classcraft|n/a|idk|i don't know|i don’t have any|guess|not sure|I studied|i studied|quizlet|this is stupid|this is dumb|^\s*(?:\S+(?:\s+\S+){0,48}\s*)?$|^(?!(?:.*?(?:^[A-Z].*?[.!?"]|\s+[A-Z].*?[.!?"])){3}).*$

How It All Works

  • Original Blocked Phrases: All your existing forbidden terms stay exactly as they are—no changes needed here.
  • Word Count Check: The final original pattern (^\s*(?:\S+(?:\s+\S+){0,48}\s*)?$) still blocks responses under 50 words.
  • Sentence Count Check: The new pattern uses a negative lookahead to verify if the response has enough valid sentences. If it doesn't, the response matches this pattern and gets rejected.

Quick Notes

  • Your sentence definition is fully supported: the pattern handles both the first sentence (no leading space, starts with uppercase) and subsequent sentences (space + uppercase start), all ending with your specified punctuation.
  • As you noted, regex isn't perfect—mid-sentence periods might cause false splits. But since you'll guide students to avoid this and design questions where mid-sentence punctuation isn't necessary, this should work reliably for your classroom needs.
  • To adjust the sentence count later, just modify the number inside the curly braces {} in the final pattern (e.g., {1} for at least 1 sentence, {4} for at least 4, etc.).

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 18:52:39