DEV Community

Ali Hamza
Ali Hamza

Posted on

Day 89 of Learning MERN Stack

Hello Dev Community! ๐Ÿ‘‹

It is officially Day 89 of my 100-day full-stack engineering run! ๐ŸŽฏ Yesterday, I kicked off my competitive solving streak on HackerRank. Today, I advanced from standard linear filters into the powerful world of textual pattern recognition by mastering: SQL Regular Expressions (REGEXP) and String Anchors! ๐Ÿ”๐Ÿ›ก๏ธ

When processing real-world data pipelinesโ€”like validating structured phone inputs, email domains, or parsing specific text queriesโ€”standard LIKE operators can make your code messy and repetitive. Today, I solved these constraints elegantly.


๐Ÿง  Shifting from Bulky LIKE Statements to Sleek REGEXP

As tracked inside my workspace files across "Screenshot (193).png" and "Screenshot (195).png", I solved two distinct core challenges from the HackerRank series:

1. Match from the Start: Weather Observation Station 6

  • The Goal: Query the list of CITY names from STATION that start with vowels (a, e, i, o, u), ensuring no duplicates are returned.
  • The Evolution: Instead of chaining multiple LIKE queries or cutting sub-strings with LEFT(), I utilized the caret anchor (^) inside a regular expression array to verify the string's starting boundary instantly:

sql
SELECT DISTINCT CITY FROM STATION 
WHERE CITY REGEXP "^(A|E|I|O|U)";
Enter fullscreen mode Exit fullscreen mode

Top comments (0)