TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Stop writing Regular Expressions – Express them with Verbal Expressions

33 pointsby adamstacalmost 12 years ago

7 comments

antichaosalmost 12 years ago
Stop writing URLs as strings. Express them with VerbalResourceLocator:<p><pre><code> var vrl = VRL(). schema(&quot;https&quot;). tld(&quot;com&quot;). sld(&quot;ycombinator&quot;). subdomain(&quot;news&quot;). path(&quot;&#x2F;item&quot;). query({&quot;id&quot;: &quot;6164276&quot;}); </code></pre> Seriously though, Verbal Expression is a great way to turn terse regexps into un-reusable verbiage that barely improves readability.
评论 #6165432 未加载
gyepialmost 12 years ago
I had never heard of this before. The stated goal is to simplify difficult regular expressions, but the examples seem to be more complicated than the corresponding regexes. Maybe I&#x27;m just old school.<p>I&#x27;m not sure that someone who relies on this would be able to debug the resulting generated regex when something doesn&#x27;t work as expected.
评论 #6164627 未加载
评论 #6164805 未加载
cleaveralmost 12 years ago
I&#x27;m always a bit wary of posts that tell me to &quot;Stop doing X&quot;. I&#x27;m also pretty comfortable with regular expressions. They take you outside of the procedural comfort zone, but are a valuable tool that will pay off to learn.<p>Still, it&#x27;s worth a shot trying to create a tool like this. What I don&#x27;t get is how they would handle subexpressions.
评论 #6167350 未加载
评论 #6164863 未加载
keithgabryelskialmost 12 years ago
when you pretend you aren&#x27;t using regular expressions, then you have two problems.
eurleifalmost 12 years ago
pyparsing (<a href="http://pyparsing.wikispaces.com/" rel="nofollow">http:&#x2F;&#x2F;pyparsing.wikispaces.com&#x2F;</a>) is more object-oriented and composable, and it can parse recursive grammars.
评论 #6164861 未加载
grkovalevalmost 12 years ago
What is news? it&#x27;s LINQ just for string
DavidSJalmost 12 years ago
Looks like cl-ppcre.