DEV Community

Cover image for Day 6: Super Expressive ✨
Valeria
Valeria

Posted on

2

Day 6: Super Expressive ✨

Ever wished for a better way to write regular expressions? If so, today is the day this dream comes true as I present to you super-expressive!

Install the dependency, e.g. with:

deno add npm:super-expressive
Enter fullscreen mode Exit fullscreen mode

Create a file, e.g. main.ts:

import SuperExpressive from "npm:super-expressive";

const regExp = SuperExpressive()
  .caseInsensitive
  .allowMultipleMatches
  .string("<strong>Find me!</strong>")
  .toRegex();

console.log(
  "Do you think you would be able to <strong>Find me!</strong>? Or Find me! So go on and <strong>Find me!</strong>".replace(
    regExp,
    "FOUND!"
  )
);

Enter fullscreen mode Exit fullscreen mode

And running the script should result in:

deno run -A ./main.ts
Do you think you would be able to FOUND!? Or Find me! So go on and FOUND!
Enter fullscreen mode Exit fullscreen mode

What do you think? Is it a nicer way to write RegExps or should we still learn how to do it manually?

Liked the content and would love to have more of it all year long?

Buy Me A Coffee

Image of AssemblyAI tool

Challenge Submission: SpeechCraft - AI-Powered Speech Analysis for Better Communication

SpeechCraft is an advanced real-time speech analytics platform that transforms spoken words into actionable insights. Using cutting-edge AI technology from AssemblyAI, it provides instant transcription while analyzing multiple dimensions of speech performance.

Read full post

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay