Menu

Post image 1
Post image 2
1 / 2
0

Regular Expressions Explained: The Visual Guide

DEV Community·Alex Chen·17 days ago
#lllytgpj
Reading 0:00
15s threshold

Regular Expressions Explained: The Visual Guide Regex doesn't have to be cryptic. Let me decode it for you. What Is Regex? Regex = pattern matching for text. Think "find and replace on steroids." Text: "My email is alex@example.com and my phone is 555-123-4567" Regex: \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b Match: alex@example.com Enter fullscreen mode Exit fullscreen mode The Core Syntax (Cheat Sheet) Character Classes . Any character (except newline) \d Digit [0-9] \D Not a digit [^0-9] \w Word character [a-zA-Z0-9_] \W Not a word character \s Whitespace (space, tab, newline) \S Not whitespace [abc] Any of a, b, or c [a-z] Any lowercase letter [0-9] Any digit (same as \d) [^abc] NOT a, b, or c Enter fullscreen mode Exit fullscreen mode Quantifiers (How Many) * Zero or more + One or more ?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More