DEV Community

Cover image for Prism and Some Thoughts On Regex
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer

Posted on

1 1

Prism and Some Thoughts On Regex

i was browsing the site of prism.js when i saw this:

Parsers fail on incorrect syntax, where regular expressions keep matching.

the author was explaining one of the decisions taken namely to use regular expressions. but, the statement above is flawed for two points

  • Parsers fail on incorrect syntax
  • regex have no link to parsers

Do Parsers Fail On Incorrect Syntax?

that one is an easy one. can't we write parsers that keep going? this point is cleared by the second one

Are Regex Different From Parsers?

regex are just another way to describe patterns be it large pieces of string like a language or just a simple piece of string like finding an email address in a paragraph.

books on compiler theory sometimes use regex instead of BNF to describe elements. looking from another angle, how does regex work, is it some native language to the computer? no, a parser has been written to understand regex and accomplish the underlying matching.

Conclusion

natural language parsing offers some interesting reflections from time to time. here is a case of the author trying to say: 'it works, let it be'

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay