How well do you know Regex?

Regex has been around for a long time and is implemented across a lot of different languages. I have used the very basics but I dont often reach for it when solving problems.

What sort of problems do you solve with regex?

I saw this post by @emma on Y’all should take a look!

1 Like

When working on a big library project, it was one of the main tools we used to transform gigabytes of cataloguing data into Solr schema docs. I got to be quite proficient with it then. Now though, I mostly reach for it to do complex find and replace in VSCode :wink:

1 Like

There was a tweet in the past few days about an awesome regex refactor - I can’t find it at the moment.

But it was a 1000x time faster by forming the Regex once rather than every time. I can’t find it now but it was something like

function email(input) {
  return '[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]'.test(input);


const email_test_string = '[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]'
function email(input) {
  return email_test_string.test(input);

Wish I could find the tweet thread but was good to remember these things can be sink-holes for performance when used in the wrong places :slight_smile:


Thanks for the link, I am going to bookmark this. I know Regex ok, had to use it alot while building out a headless WordPress project. We parsed alot of WordPress Gutenberg post blocks from the WP API using regex in order to transform it how we wanted. I think for me I get better at it by using it more.