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.

Regular expression to match a chemical element

5 pointsby kevinover 9 years ago

1 comment

colandermanover 9 years ago
How about just &#x2F;Ac|Ag|Al|Am...&#x2F;. Let the regex compiler do the work for you, and keep it readable and maintainable.<p>(A true regular expression is compiled to a DFA, which is unique for the set of input strings matched, so there is nothing to gain performance-wise from factoring out common prefixes. That is quite literally the job of the compiler.)