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

请求参数batchId的正则表达式匹配规则定制需求

Regex to Validate batchId Format (yyyyMMdd_ or yyyyMMdd_end)

Got it, let's fix that regex to properly enforce your batchId rules. Here's the pattern you need:

^\d{8}_(\d+|(?i)end)$

Let's break down what each part does:

  • ^ and $: These anchor the regex to the start and end of the string, so we don't get partial matches (like a valid prefix with extra junk at the end).
  • \d{8}: Ensures we have exactly 8 digits for the yyyyMMdd date prefix.
  • _: Matches the literal underscore separator.
  • The group (\d+|(?i)end) handles the suffix:
    • \d+: Matches one or more digits (covers any attempt count, from 001 up to 9999999 like your examples).
    • (?i)end: Makes the "end" match case-insensitive, so END, End, eNd, etc., all work for the final call marker.

Examples of valid batchIds:

  • 20200509_001 (first attempt)
  • 20200509_9999999 (high attempt count)
  • 20200509_end (lowercase end)
  • 20200509_END (uppercase end)

Examples of invalid batchIds that will be rejected:

  • 20200509_ (no suffix after underscore)
  • 20200509_abc123 (invalid characters in suffix)
  • 2020059_001 (only 7 digits in the date prefix)
  • 20200509_end123 (extra characters after "end")

If you need to limit the number of digits allowed for the attempt count (e.g., max 7 digits as in your example), you can tweak the digit part to \d{1,7} instead of \d+—that would restrict it to 1-7 digits.

内容的提问来源于stack exchange,提问作者shrikant.sharma

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.07 15:42:59