DIY Regular Expressions

In the Star Wars universe, not everyone uses a lightsabe, and those who do wield them had to build them themselves. There’s something to be said about that strategy. Building a car or a radio is a great way to learn how those things work. That’s what [Low Level JavaScript] points out about regular expressions. Sure, a lot of people think they are scary. So why not write your own regular expression parser and engine? Get that under your belt and you’ll probably never fear another regular expression.

Of course, most of us probably won’t do it ourselves, but you can still watch the process in the video below. The code is surprisingly short, but don’t expect all the bells and whistles you might find in Python or even Perl.

In the hands of the skilled, regular expressions are very powerful and offer a quick way to split apart text data. Like a lot of powerful ideas, the basic concept — that of a finite state machine — is really simple. It is the application to real problems that becomes difficult.

If you want a primer on regular expressions that doesn’t require you to write your own tools, we have had a few posts that can help. If you just want some practice, try a crossword puzzle.



from Blog – Hackaday https://ift.tt/2HMInmJ

Comments

Popular posts from this blog

Modern Radio Receiver Architecture: From Regenerative to Direct Conversion

Hackaday Links: May 31, 2020

Homebrew 68K Micro-ATX Computer Runs Its Own OS