TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The Regular Expression Visualizer, Simulator and Cross-Compiler Tool

197 点作者 robertelder将近 5 年前

9 条评论

robertelder将近 5 年前
Hi, I'm the author of this page. This tool has a lot of complexity in it and a huge number of corner-cases. If you discover any bugs or XSS vulnerabilities, feel free to let me know.
评论 #23975661 未加载
评论 #23979371 未加载
评论 #23975961 未加载
评论 #23975695 未加载
hprotagonist将近 5 年前
along these lines, <a href="https:&#x2F;&#x2F;regex101.com" rel="nofollow">https:&#x2F;&#x2F;regex101.com</a> is consistently a godsend for writing regex.
评论 #23979865 未加载
评论 #23977399 未加载
评论 #23975630 未加载
评论 #23980966 未加载
jjice将近 5 年前
I would have loved this when I worked on a regex engine a few years back. It was before I took my CS theory course and had no idea what an automaton was. Let me tell you, having a formal theory and visualization in front of you while working on something is extremely helpful.<p>This looks like it would be a great tool for both people looking to learn, and those who are looking to optimize their regular expressions as well.
maddyboo将近 5 年前
When I read the title, I half hoped ‘cross-compiler’ referred to translating between different regex varieties. Anyone know of a tool that does this?
gfxgirl将近 5 年前
Any one write an AST aware regex engine?<p>Examples: replace s&#x2F;(?ast:comment)foo&#x2F;bar to replace foo with bar but only in comments. Or s&#x2F;(\w+): (?ast:openparent)(.<i>?)(?ast:closeparen)\s+(?ast:openbracked)(.</i>?)(?ast:closebracket)&#x2F;function $1($2)\n{\n$3\n}\n&#x2F; to convert from<p><pre><code> foo: (args) { codeblock } </code></pre> to<p><pre><code> function foo(args) { codeblock } </code></pre> etc..?
评论 #23978432 未加载
评论 #23978446 未加载
评论 #23976757 未加载
twistedpair将近 5 年前
Nice graphical explanations! It would be nice to see positive&#x2F;negative look ahead&#x2F;behind support as they&#x27;re pretty powerful.<p>The `\K` flag to clear the capture buffer (e.g. Perl flavor) is also a very useful regexp feature absent here (e.g. when testing `grep` commands).
x87678r将近 5 年前
Any suggestions to keep regexes simple? They often grow to huge lengths which are hard to read and&#x2F;or debug. It would be nice to keep modular. Maybe using websites like this is the only way.
评论 #23978810 未加载
chubot将近 5 年前
Note that when you use grep, awk, sed, libc regexec(), RE2 [1], or rust&#x2F;regex, this isn&#x27;t how your regexes are executed.<p>They use automata-based engines whereas this is a backtracking engine, which can blow up on small inputs. (Although I will say the C code here is cool, because it gives you a fork() bomb, so it might exhaust your operating system and not just your CPU!)<p>Canonical reference: <i>Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)</i><p><a href="https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp1.html" rel="nofollow">https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp1.html</a><p>Archive since it&#x27;s down at the moment due to some App Engine stuff (!): <a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20200624195819&#x2F;https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp1.html" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20200624195819&#x2F;https:&#x2F;&#x2F;swtch.com...</a><p>My blog post and sample code that verifies that GNU grep, awk, sed, and libc don&#x27;t backtrack:<p><i>Comments on Eggex and Regular Languages</i> <a href="http:&#x2F;&#x2F;www.oilshell.org&#x2F;blog&#x2F;2020&#x2F;07&#x2F;eggex-theory.html" rel="nofollow">http:&#x2F;&#x2F;www.oilshell.org&#x2F;blog&#x2F;2020&#x2F;07&#x2F;eggex-theory.html</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;oilshell&#x2F;blog-code&#x2F;tree&#x2F;master&#x2F;regular-languages" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;oilshell&#x2F;blog-code&#x2F;tree&#x2F;master&#x2F;regular-la...</a><p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;re2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;re2</a><p>----<p>Also, the production quality way of compiling regular expressions to C code looks like this [2], which is completely different than what&#x27;s shown in the article:<p><a href="https:&#x2F;&#x2F;www.oilshell.org&#x2F;release&#x2F;0.8.pre8&#x2F;source-code.wwz&#x2F;_devbuild&#x2F;gen&#x2F;osh-lex.h" rel="nofollow">https:&#x2F;&#x2F;www.oilshell.org&#x2F;release&#x2F;0.8.pre8&#x2F;source-code.wwz&#x2F;_d...</a><p>The regex is converted to an NFA, then a DFA, then a bunch of switch&#x2F;goto statements in C that implement the DFA.<p>This example is huge, but the switch&#x2F;goto and lack of any notion of &quot;threading&quot; is the important point.<p>Essentially, the instruction pointer is used as the DFA state. It&#x27;s a very natural use of &quot;goto&quot; (where you don&#x27;t write or debug them yourself)<p>[2] via <a href="http:&#x2F;&#x2F;re2c.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;re2c.org&#x2F;</a> (not related to RE2)
评论 #23978804 未加载
评论 #23979121 未加载
vmchale将近 5 年前
neato bandito