🔍

首页Home › 随机生成Random Generators

⧉ 由正则生成随机串Generate Random Data from Regexp

根据正则表达式生成随机字符串:支持 \d \w \s(及大写取反)、.、[...] 与 [^...]、分组 (...) 和 (?:...)、任意位置的 | 选择、? * + {2} {2,} {2,5} 形式的量词以及 ^ $ 锚点。本地处理。Generate random strings from a regular expression: \d \w \s (and their negations), ., [...] and [^...] classes, (...) and (?:...) groups, | alternation anywhere, ? * + quantifiers such as {2} {2,} {2,5} and the ^ $ anchors. Processed locally.

使用说明与常见问题How-to & FAQ

「由正则生成随机串」是什么?What is the Generate Random Data from Regexp tool?

根据正则表达式生成随机字符串:支持 \d \w \s(及大写取反)、.、[...] 与 [^...]、分组 (...) 和 (?:...)、任意位置的 | 选择、? * + {2} {2,} {2,5} 形式的量词以及 ^ $ 锚点。本地处理。Generate random strings from a regular expression: \d \w \s (and their negations), ., [...] and [^...] classes, (...) and (?:...) groups, | alternation anywhere, ? * + quantifiers such as {2} {2,} {2,5} and the ^ $ anchors. Processed locally.

如何使用「由正则生成随机串」?How do I use the Generate Random Data from Regexp tool?

在「由正则生成随机串」中,按需设置「条数」、「正则模式」、「种子(留空 = 安全随机)」,结果会实时显示在下方,点击「复制结果」即可复制。In the Generate Random Data from Regexp: Adjust "How many", "Pattern", "Seed (blank = secure random)"; the result appears below instantly — click "Copy result" to copy it.

支持哪些正则语法?Which regex syntax is supported?

支持:普通字符(含中文和 emoji)、转义 \d \w \s 及其取反 \D \W \S、\n \t \uXXXX、.、字符集合 [a-z0-9] 和取反集合 [^...]、分组 (...) 与 (?:...)、任意位置的 | 选择(例如 cat|dog 或 x(a|b)y)、量词 ? * + {m} {m,} {m,n},以及作为位置标记的 ^ 和 $(不会出现在结果里)。前瞻/后顾、反向引用 \1、单词边界 \b 和 \p{…} 不支持,会直接报错;写法本身无效(如 (abc、a)b、[z-a])也会报错,不会悄悄生成别的内容。Supported: ordinary characters (including CJK and emoji), the escapes \d \w \s and their negations \D \W \S, \n \t \uXXXX, ., classes such as [a-z0-9] and negated classes [^...], groups (...) and (?:...), | alternation anywhere (cat|dog or x(a|b)y), the quantifiers ? * + {m} {m,} {m,n}, and the anchors ^ and $, which only mark positions and never appear in the output. Lookahead/lookbehind, backreferences such as \1, word boundaries \b and \p{…} are not supported and give an error; so does invalid syntax such as (abc, a)b or [z-a] — nothing is silently generated instead.

重复次数有上限吗?Is there a limit on repetition?

有。* 和 + 以及 {m,} 这种没有上限的量词,最多比下限多重复 8 次(结果下方会提示);明确写出的次数 {m} / {m,n} 最多 1000;每条结果最多 10,000 个字符,超过会报错。条数为 1–100。Yes. * and + and open-ended {m,} repeat at most 8 times more than their minimum (a note below the result says so); explicit counts {m} / {m,n} can be at most 1,000; each generated string is limited to 10,000 characters, and longer results give an error. How many: 1–100.

. 和取反集合会生成哪些字符?Which characters do . and negated classes produce?

. 从英文字母和数字中选;[^...]、\D、\W、\S 从可打印 ASCII 字符(空格到 ~)中去掉被排除的字符后再选。所有字符都按完整的 Unicode 码位处理,所以 😀{2} 得到两个完整的 😀,不会出现半个 emoji。. picks from English letters and digits; [^...], \D, \W and \S pick from the printable ASCII characters (space to ~) minus the excluded ones. Everything works on whole Unicode code points, so 😀{2} gives two complete 😀 and never half an emoji.

结果是真随机的吗?「种子」有什么用?Is the output truly random? What does Seed do?

「种子」留空(默认)时,结果用浏览器的 crypto.getRandomValues(密码学安全随机数)生成,每次都不同,每种结果出现的概率相同(偏差小于千万亿分之一)。填写种子后改用确定性的伪随机数生成器(mulberry32):同一种子总是得到同样的结果,便于复现,但结果可以被预测,不要把带种子的结果用于密码或需要公证的抽奖。With Seed left blank (the default), the output comes from the browser's crypto.getRandomValues (cryptographically secure randomness), so it differs every time and every outcome is equally likely (any bias is below one in a million billion). If you enter a seed, a deterministic pseudo-random generator (mulberry32) is used instead: the same seed always gives the same output, which is handy for reproducing a result, but it is predictable, so do not use seeded output for passwords or audited draws.

输入和输出是什么样的?What does the input and output look like?

例如在「由正则生成随机串」中把「条数」设为 2,「正则模式」设为 A{2},「种子」设为 1,输出为:AA ⏎ AA(⏎ 表示换行)。For example, in the Generate Random Data from Regexp with "How many" set to 2, "Pattern" set to A{2}, "Seed" set to 1, the output is: AA ⏎ AA (⏎ marks a line break).

有哪些选项可以调整?What options can I adjust?

「由正则生成随机串」的设置:「条数」默认 5;「正则模式」默认 [A-Z]{3}-\d{3};「种子(留空 = 安全随机)」可留空。每次生成结果都按当前设置处理。Settings in the Generate Random Data from Regexp — "How many" default 5; "Pattern" default [A-Z]{3}-\d{3}; "Seed (blank = secure random)" optional. The result always uses the current settings.

「由正则生成随机串」免费吗?需要注册吗?Is the Generate Random Data from Regexp free? Do I need an account?

「由正则生成随机串」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Generate Random Data from Regexp is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.

相关工具Related tools

🔤 生成随机字母Generate Random Alphabet Letters🔢 生成随机数字对Generate Random Digit Pairs₈ 生成随机八进制数Generate Random Octal Numbers🎲 随机挑一个数字Pick Random Digit🏆 随机抽奖 / 挑赢家Pick Winner🆔 UUID 生成器UUID Generator🔑 随机密码生成器Password Generator🎰 随机数生成器Random Number Generator🎲 抛硬币 / 掷骰子Coin Flip & Dice Roller🔤 随机字符串生成器Random String Generator📅 随机日期生成器Random Date Generator🔢 数字序列生成器Number Sequence Generator

← 全部工具All tools