r/ProgrammerHumor • • Mar 20 '24

Meme areJSDevsActuallySane

Post image
14k Upvotes

554 comments sorted by

View all comments

Show parent comment

6

u/unipleb Mar 20 '24

Now I'm wondering if it's possible to check if a string matches elements in the periodic table using one big regex

3

u/[deleted] Mar 21 '24

Yes, but if you write it out then it summons Luficer, or Adam's housecat or the ghosts of long gone Hannah-Barbera characters. What's worse, the spell to make them go away is to write out the regex that matches everything except element names.

Seriously, yes, if you can create a DFA to do it, you can write it as a regex.

1

u/Antrikshy Mar 20 '24

You better hook that regex up to Wikipedia or something so it's up to date when new elements are discovered/synthesized.