SlideShare a Scribd company logo
5
Most read
10
Most read
11
Most read
Regular
Expressions
Presentedby:
Khuda Bux Magsi
(CSC-23F-259)
Context
• Introduction to Regular Expression
• Basic Syntax and Metacharacters
• Practical Applications
• Regex Tools
• Conclusion
Introduction
About Regular Expressions
What’s a Regular Expression?
• Regular expressions originated in 1951, when
mathematician Stephen Cole Kleene described regular
languages using his mathematical notation called regular
events.
• A regular expression, or regex, is a sequence of characters
used to define a search pattern.
• It's a powerful tool for finding, matching, and manipulating
text within a larger body of data.
• Regular Expressions are supported by many programming
languages and tools, making them a widely used tool in
software development.
What’s a Regular Expressions?
Example
Basic Syntax
Basic Syntax and Metacharacters
Basic Syntax of Regular
Expression
Regular expressions (regex) consist of a combination of literals and metacharacters that create
search patterns for matching text. Understanding the basic syntax is crucial for crafting
effective regex patterns.
Regular expressions (regex) have a specific syntax that defines how patterns are constructed.
Here's a breakdown of some fundamental elements:
 Literal Characters
 Special Characters
 Quantifiers
 Grouping
 Alternation
Basic Syntax of Regular
Expression
 Literal Characters
A literal character is any character that represents itself and is not interpreted as a
special symbol or metacharacter in regex. For instance, the letter a in a regex
pattern will match the character 'a' in the input text.
Examples of Literal Characters
Here are a few simple regex patterns using literal characters:
• ‘cat’: Matches the substring 'cat' in the text.
• Example: The cat is sleeping. (Matches 'cat')
Basic Syntax of Regular
Expression
 Special Characters
These are the workhorses of regex, adding power and flexibility to your patterns. Some common ones
include:
 . (Dot): Matches any single character except for newline characters.
 [] (Brackets): Define a set of characters that can match at a specific position. For example, "[abc]"
will match any of the letters a, b, or c.
 *(Asterisk): Matches the preceding character zero or more times. So, "a*b" will match "b", "ab",
"aab", "aaab", and so on.
 + (Plus): Matches the preceding character one or more times. "a+b" will match "ab", "aab", "aaab",
and so on, but not just "b".
 ? (Question Mark): Matches the preceding character zero or one time. "ca?t" will match "cat" or
"ct".
Basic Syntax of Regular
Expression
 Quantifiers:
These are special characters like "*", "+", and "?" that specify how many times the preceding character or group can be repeated.
Basic Syntax of Regular
Expression
 Grouping:
Parentheses are used to group parts of the pattern. This allows you to apply quantifiers or other operations to the entire group. For
instance, "(ab)*c" will match "c", "abc", "abbc", "abbbc", and so on.
Basic Syntax of Regular
Expression
 Alternation:
The pipe symbol ("|") is used for alternation. For example, "apple|banana" will match either "apple" or "banana".
Practical
Application
In Regular Expression
Validating Input
• Validating user input is crucial for ensuring data integrity and security in applications.
Here are common validation techniques for specific types of user input.
Searching and Replacing
• Searching and replacing text based on patterns is a common task in text processing. Here
are examples of how to search for patterns and replace them with desired text.
Regex Tools &
Libraries
Regular Expression
Regex Tools
Online Regex Testers
 Regex101: An interactive web-based tool that supports
multiple regex flavors, including PCRE, JavaScript, and
Python. It provides real-time regex matching, a detailed
explanation of the regex, and a breakdown of each
component.
 RegExr: Another online tool that offers a user-friendly
interface for creating and testing regular expressions. It
includes a library of regex snippets and a cheat sheet for
common patterns.
 RegexPlanet: Supports various programming languages,
providing a versatile platform for testing regex patterns
against sample text.
Regex Tools
Integrated Development Environment (IDE) Plugins
 Regex Plugin for Visual Studio Code: Enhances the regex capabilities within the VSCode
environment, allowing for testing and debugging regex patterns directly in the editor.
 IntelliJ IDEA Regex Plugin: Provides similar functionality for IntelliJ-based IDEs, offering syntax
highlighting, pattern matching, and error detection.
Conclusion
 Indispensable Tool:
• Regular expressions are essential for modern programming and text processing.
• They provide a flexible and powerful method for searching, matching, and manipulating
strings.
 Versatile Applications:
• Useful for a wide range of tasks, from simple text searches to complex parsing and data
extraction.
• Applicable in various domains, including data validation, web scraping, and log file analysis.
Thank you
Any
Question..
Feel free to ask

More Related Content

ODP
CiNPA Security SIG - Regex Presentation
ODP
OISF: Regular Expressions (Regex) Overview
ODP
DerbyCon 7.0 Legacy: Regular Expressions (Regex) Overview
PDF
Week-2: Theory & Practice of Data Cleaning: Regular Expressions in Theory
PPT
RegEx : Expressions and Parsing Examples
PDF
Regular expressions
KEY
Regular Expressions 101
PPTX
Regular Expressions
CiNPA Security SIG - Regex Presentation
OISF: Regular Expressions (Regex) Overview
DerbyCon 7.0 Legacy: Regular Expressions (Regex) Overview
Week-2: Theory & Practice of Data Cleaning: Regular Expressions in Theory
RegEx : Expressions and Parsing Examples
Regular expressions
Regular Expressions 101
Regular Expressions

Similar to Regular Expressions(Theory of programming languages)) (20)

PPTX
Regular Expression
PPT
RegEx Parsing
PPTX
Regular Expression Crash Course
ODP
Regex Presentation
ODP
Regex Presentation
PDF
Regular Expressions 101
PDF
Python (regular expression)
ODP
Regular Expressions and You
PPT
Adv. python regular expression by Rj
PPTX
Regular expressions
PPTX
Mikhail Khristophorov "Introduction to Regular Expressions"
PPTX
Regular Expressions Introduction Anthony Rudd CS
PPTX
Common regex pp functions wweweewwt.pptx
PPTX
Finaal application on regular expression
PDF
Regular expression in python for students
PPTX
NUS_NLP__Foundations_-_Section_2_-_Words.pptx
DOCX
Python - Regular Expressions
PDF
Construction of a predictive parsing table.pdf
PPT
Chapter-three automata and complexity theory.ppt
PDF
Python Programming - XI. String Manipulation and Regular Expressions
Regular Expression
RegEx Parsing
Regular Expression Crash Course
Regex Presentation
Regex Presentation
Regular Expressions 101
Python (regular expression)
Regular Expressions and You
Adv. python regular expression by Rj
Regular expressions
Mikhail Khristophorov "Introduction to Regular Expressions"
Regular Expressions Introduction Anthony Rudd CS
Common regex pp functions wweweewwt.pptx
Finaal application on regular expression
Regular expression in python for students
NUS_NLP__Foundations_-_Section_2_-_Words.pptx
Python - Regular Expressions
Construction of a predictive parsing table.pdf
Chapter-three automata and complexity theory.ppt
Python Programming - XI. String Manipulation and Regular Expressions
Ad

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PPTX
master seminar digital applications in india
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Classroom Observation Tools for Teachers
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Pre independence Education in Inndia.pdf
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Complications of Minimal Access Surgery at WLH
master seminar digital applications in india
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Classroom Observation Tools for Teachers
VCE English Exam - Section C Student Revision Booklet
human mycosis Human fungal infections are called human mycosis..pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Supply Chain Operations Speaking Notes -ICLT Program
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
TR - Agricultural Crops Production NC III.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial disease of the cardiovascular and lymphatic systems
2.FourierTransform-ShortQuestionswithAnswers.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Pre independence Education in Inndia.pdf
Sports Quiz easy sports quiz sports quiz
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Ad

Regular Expressions(Theory of programming languages))

  • 2. Context • Introduction to Regular Expression • Basic Syntax and Metacharacters • Practical Applications • Regex Tools • Conclusion
  • 4. What’s a Regular Expression? • Regular expressions originated in 1951, when mathematician Stephen Cole Kleene described regular languages using his mathematical notation called regular events. • A regular expression, or regex, is a sequence of characters used to define a search pattern. • It's a powerful tool for finding, matching, and manipulating text within a larger body of data. • Regular Expressions are supported by many programming languages and tools, making them a widely used tool in software development.
  • 5. What’s a Regular Expressions? Example
  • 6. Basic Syntax Basic Syntax and Metacharacters
  • 7. Basic Syntax of Regular Expression Regular expressions (regex) consist of a combination of literals and metacharacters that create search patterns for matching text. Understanding the basic syntax is crucial for crafting effective regex patterns. Regular expressions (regex) have a specific syntax that defines how patterns are constructed. Here's a breakdown of some fundamental elements:  Literal Characters  Special Characters  Quantifiers  Grouping  Alternation
  • 8. Basic Syntax of Regular Expression  Literal Characters A literal character is any character that represents itself and is not interpreted as a special symbol or metacharacter in regex. For instance, the letter a in a regex pattern will match the character 'a' in the input text. Examples of Literal Characters Here are a few simple regex patterns using literal characters: • ‘cat’: Matches the substring 'cat' in the text. • Example: The cat is sleeping. (Matches 'cat')
  • 9. Basic Syntax of Regular Expression  Special Characters These are the workhorses of regex, adding power and flexibility to your patterns. Some common ones include:  . (Dot): Matches any single character except for newline characters.  [] (Brackets): Define a set of characters that can match at a specific position. For example, "[abc]" will match any of the letters a, b, or c.  *(Asterisk): Matches the preceding character zero or more times. So, "a*b" will match "b", "ab", "aab", "aaab", and so on.  + (Plus): Matches the preceding character one or more times. "a+b" will match "ab", "aab", "aaab", and so on, but not just "b".  ? (Question Mark): Matches the preceding character zero or one time. "ca?t" will match "cat" or "ct".
  • 10. Basic Syntax of Regular Expression  Quantifiers: These are special characters like "*", "+", and "?" that specify how many times the preceding character or group can be repeated.
  • 11. Basic Syntax of Regular Expression  Grouping: Parentheses are used to group parts of the pattern. This allows you to apply quantifiers or other operations to the entire group. For instance, "(ab)*c" will match "c", "abc", "abbc", "abbbc", and so on.
  • 12. Basic Syntax of Regular Expression  Alternation: The pipe symbol ("|") is used for alternation. For example, "apple|banana" will match either "apple" or "banana".
  • 14. Validating Input • Validating user input is crucial for ensuring data integrity and security in applications. Here are common validation techniques for specific types of user input.
  • 15. Searching and Replacing • Searching and replacing text based on patterns is a common task in text processing. Here are examples of how to search for patterns and replace them with desired text.
  • 17. Regex Tools Online Regex Testers  Regex101: An interactive web-based tool that supports multiple regex flavors, including PCRE, JavaScript, and Python. It provides real-time regex matching, a detailed explanation of the regex, and a breakdown of each component.  RegExr: Another online tool that offers a user-friendly interface for creating and testing regular expressions. It includes a library of regex snippets and a cheat sheet for common patterns.  RegexPlanet: Supports various programming languages, providing a versatile platform for testing regex patterns against sample text.
  • 18. Regex Tools Integrated Development Environment (IDE) Plugins  Regex Plugin for Visual Studio Code: Enhances the regex capabilities within the VSCode environment, allowing for testing and debugging regex patterns directly in the editor.  IntelliJ IDEA Regex Plugin: Provides similar functionality for IntelliJ-based IDEs, offering syntax highlighting, pattern matching, and error detection.
  • 19. Conclusion  Indispensable Tool: • Regular expressions are essential for modern programming and text processing. • They provide a flexible and powerful method for searching, matching, and manipulating strings.  Versatile Applications: • Useful for a wide range of tasks, from simple text searches to complex parsing and data extraction. • Applicable in various domains, including data validation, web scraping, and log file analysis.