What is Regex | Regular Expression 🪄

Опубликовано: 03 Май 2025
на канале: AmsR HuB
37
like

Regular expressions (regex) are patterns used to match and manipulate strings. Here are some key concepts:

Basic Concepts
1. *Patterns*: Regex patterns are used to match strings.
2. *Literal characters*: Most characters match themselves (e.g., "a" matches "a").
3. *Special characters*: Some characters have special meanings (e.g., "." matches any character).

Common Regex Patterns
1. *.*: Matches any single character.
2. *\w*: Matches word characters (letters, digits, or underscores).
3. *\W*: Matches non-word characters.
4. *\d*: Matches digits.
5. *\D*: Matches non-digits.
6. *\s*: Matches whitespace characters.
7. *\S*: Matches non-whitespace characters.

Quantifiers
1. ***: Matches 0 or more occurrences.
2. *+*: Matches 1 or more occurrences.
3. *?*: Matches 0 or 1 occurrence.
4. *{n}*: Matches exactly n occurrences.
5. *{n,}*: Matches n or more occurrences.
6. *{n,m}*: Matches between n and m occurrences.

Anchors
1. *^*: Matches the start of a string.
2. *$*: Matches the end of a string.

Groups and Capturing
1. *()*: Groups patterns and captures matches.
2. *\1*, *\2*, etc.: References captured groups.

Regex Methods
1. *test()*: Tests if a string matches a regex pattern.
2. *exec()*: Executes a regex pattern on a string and returns matches.
3. *match()*: Returns an array of matches.
4. *replace()*: Replaces matches with a replacement string.

Example

const regex = /\d+/g;
const string = "Hello123World456";
const matches = string.match(regex);
console.log(matches); // Output: ["123", "456"]

Use Cases
1. *Validation*: Validate user input (e.g., email addresses, phone numbers).
2. *Extraction*: Extract data from strings (e.g., parsing log files).
3. *Replacement*: Replace substrings in strings.

By mastering regex, you can efficiently work with strings and perform complex text processing tasks.

📒 Get Notes here:
https://chat.whatsapp.com/GLJ3nFxD3K7...
🧑🏻‍💻 Get Code here: https://github.com/Aryan0-1Maurya

📌 Bookmark this Playlist:
   • Javascript Mastery | Js for Beginners...  

   • Web Development | Full Stack | 10 to ...  

🥳 Join our WhatsApp Community:
WhatsApp group: https://chat.whatsapp.com/GLJ3nFxD3K7...

🚀 Follow me on:
Instagram:   / amsrhub01  
Linkedin:   / aryan-maurya-692047253  
GitHub:
https://github.com/Aryan0-1Maurya
Codepen:https://codepen.io/aryan-maurya-amsr/
Facebook:https://www.facebook.com/profile.php?...
Group:https://chat.whatsapp.com/GLJ3nFxD3K7...
YouTube:   / @amsr-hub  
Linktree: https://linktr.ee/amsrhub

Hashtags:
#coding #regexp #regex #regularexpressions #javadatatypes #javascript

Ignore these Tags:

web development full course
web development amsrhub
web development roadmap
web development
aryan maurya
roadmap for web development
Javascript full course
animation in js
Javascript in web development
beautiful website in web development
Js basics
Javascript in one video
full stack web development course
web development course
web development roadmap 2024
web dev roadmap 2025
amsr hub css
Js asmr hub
aryan sir js coding
front end developer roadmap
anuj bhaiya web development
full stack developer roadmap
full stack web development roadmap
web development roadmap 2024
web developer roadmap
roadmap to web development
backend web development
best web development course
web designing full course
code with harry web development course
apna college web development
web development full course in hindi
website development
frontend developer roadmap
web development projects
front end developer course
traversy media web development
full stack web development
full web development course
full stack developer
how to learn web development
complete web developer course
roadmap for front end developer
web development anuj bhaiya
complete roadmap for web development
what is web development
full stack developer course
front end web development full course
web development road map
web developer course
backend developer roadmap
web developer roadmap 2024
android development
front end developer
complete web development course
front end roadmap
love babbar web development
web dev
javascript roadmap
roadmap
love babbar web development roadmap
front end development tutorial
web development tutorial
website development course
roadmap of web development
web developer
front end development roadmap
web development aman dhattarwal
web developer roadmap 2025
code with harry web development
backend web development roadmap
aman dhattarwal web development
javascript full course
web development projects for final year
web development projects for resume
web development project
projects for resume
mern stack projects for resume
web dev projects
full stack project