SlideShare a Scribd company logo
1 of 21
REGEX (REGULAR EXPRESSION)
STIKOM Artha Buana
Teknik Informatika
2014
Ir. Ahmad Haidaroh, M.Kom.
Regular expressions
• FSA (NFSA atau DFSA) merupakan cetak biru
(blueprint) untuk membuat suatu mesin yang
dapat mengenali regular language (RL).
• Regex merupakan cara pendeklarasian RL
yang ramah pengguna (user-friendly).
• Contoh: 01* + 10*
- 2
STIKOM Artha Buana
Regular expressions
• Regex digunakan, misalnya pada:
• Perintah grep UNIX
• Tools Lex (Lexical analyzer generator) dan
Flex (Fast Lex) UNIX
- 3
STIKOM Artha Buana
• Regular Language Finite Automata
• Regular Language  Regular Expressions
• Finite Automata  Regular Expressions
- 4
STIKOM Artha Buana
• Regular Language Finite Automata
• Regular Language  Regular Expressions
• Finite Automata  Regular Expressions
- 5
STIKOM Artha Buana
• Regular Language Finite Automata
• Regular Language  Regular Expressions
• Finite Automata  Regular Expressions
- 6
STIKOM Artha Buana
Review (Operasi Bahasa)
• Gabungan (Union)
L  M = {w | w  L atau w  M}
• Sambungan (Konkatenasi)
LM = {w | w = xy, x  L atau y  M}
• Pangkat
L0 = {}, L1= L, Lk+1= LLk
• Klosur
L* = 𝑖=0
∞
𝐿𝑖
- 7
STIKOM Artha Buana
x = 01101 dan y = 110
Maka xy = 01101110 dan yx = 11001101
Jika L = {001, 10, 111} dan M = {, 001} maka
L.M = {001, 10, 111, 001001, 10001, 111001}
Regular
Language
Regular Language & Regular Expressions
Contoh 1:
r = (a + b.c)*
L(r) = {a,bc}*
L(r) = {, a, bc, aa, abc, bca, …}
- 8
STIKOM Artha Buana
Regular Expressions
Regular Language & Regular Expressions
Contoh 2:
r = (a + b)*(a + bb)
L(r) = {a, bb, aa, abb, ba, bbb, …}
- 9
STIKOM Artha Buana
Regular Language & Regular Expressions
Contoh 3:
r = (aa)*(bb)*b
L(r) = {a2nb2mb | n,m ≥ 1}
- 10
STIKOM Artha Buana
Regular Language & Regular Expressions
Contoh 4:
r = (aa)*(bb)*b
L(r) = {a2nb2mb | n,m ≥ 0}
- 11
STIKOM Artha Buana
Regular Language & Regular Expressions
Contoh 5:
r = (0+1)*00(0+1)*
L(r) = {semua string yang memiliki
sekurangnya dua 0 berurutan}
- 12
STIKOM Artha Buana
Regular Language & Regular Expressions
Contoh 6:
r = (1+01)*(0+)
L(r) = {semua string tanpa dua 0
berurutan}
)
0
(
*
)
01
1
( 



r
- 13
STIKOM Artha Buana
• Regular Language Finite Automata
• Regular Language  Regular Expressions
• Finite Automata  Regular Expressions
- 14
STIKOM Artha Buana
KONVERSI dr DFSA  RE
Contoh 1:
• Buatlah RE dari DFSA berikut
• Konversikan dalam bentuk RE
- 15
STIKOM Artha Buana
• Eliminasi Keadaan 1, menjadi:
• Konversi dalam bentuk RE
- 16
STIKOM Artha Buana
KONVERSI dr DFSA  RE
• RE dari DFSA : (0+10)*11(0+1)*
• Eliminasi Keadaan 1
- 17
STIKOM Artha Buana
Ingat ! : State Input dan Output harus selalu ada
KONVERSI dr DFSA  RE
Contoh 2:
• Buatlah RE dari DFSA yang dapat menerima 1
berjumlah genap
• Eliminasi Keadaan 2, menjadi
- 18
STIKOM Artha Buana
0+10*1
KONVERSI dr DFSA  RE
• Dua keadaan akhir, matikan Keadaan 3 dahulu!
• Hasilnya 0* karena yang menuju Keadaan 3 tidak
akan diterima FSA (seharusnya finish di 3)
- 19
STIKOM Artha Buana
0+10*1
KONVERSI dr DFSA  RE
• Selanjutnya, matikan Keadaan 1!
• Hasilnya (10*1(0+10*1)
- 20
STIKOM Artha Buana
KONVERSI dr DFSA  RE
• Dikombinasikan dengan hasil sebelumnya,
menjadi: (0*+10*1(0+10*1)
- 21
STIKOM Artha Buana
KONVERSI dr DFSA  RE

More Related Content

What's hot

Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Srimatre K
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEAbhishek Shivhare
 
Finite Automata
Finite AutomataFinite Automata
Finite Automataparmeet834
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsgrahamwell
 
Admissions in india
Admissions in indiaAdmissions in india
Admissions in indiaEdhole.com
 
Theory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite AcceptorsTheory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite AcceptorsRushabh2428
 
SPIRE2013-tabei20131009
SPIRE2013-tabei20131009SPIRE2013-tabei20131009
SPIRE2013-tabei20131009Yasuo Tabei
 
Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Kai Katsumata
 

What's hot (17)

Formal Grammars
Formal GrammarsFormal Grammars
Formal Grammars
 
Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2Formal Languages and Automata Theory unit 2
Formal Languages and Automata Theory unit 2
 
Syntax Definition
Syntax DefinitionSyntax Definition
Syntax Definition
 
LL Parsing
LL ParsingLL Parsing
LL Parsing
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Syntax Definition
Syntax DefinitionSyntax Definition
Syntax Definition
 
automata problems
automata problemsautomata problems
automata problems
 
PUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINEPUSH DOWN AUTOMATA VS TURING MACHINE
PUSH DOWN AUTOMATA VS TURING MACHINE
 
Cs419 lec6 lexical analysis using nfa
Cs419 lec6   lexical analysis using nfaCs419 lec6   lexical analysis using nfa
Cs419 lec6 lexical analysis using nfa
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Static Analysis
Static AnalysisStatic Analysis
Static Analysis
 
Admissions in india
Admissions in indiaAdmissions in india
Admissions in india
 
Theory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite AcceptorsTheory of Computation Basics of Finite Acceptors
Theory of Computation Basics of Finite Acceptors
 
SPIRE2013-tabei20131009
SPIRE2013-tabei20131009SPIRE2013-tabei20131009
SPIRE2013-tabei20131009
 
Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法
 

Similar to Materi 4 Regular Expression

Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdfkenilpatel65
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler DesignKuppusamy P
 
Regular expressions h1
Regular expressions h1Regular expressions h1
Regular expressions h1Rajendran
 
Theory of computing
Theory of computingTheory of computing
Theory of computingRanjan Kumar
 

Similar to Materi 4 Regular Expression (7)

UNIT 1 part II.ppt
UNIT 1 part II.pptUNIT 1 part II.ppt
UNIT 1 part II.ppt
 
Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdf
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular expressions h1
Regular expressions h1Regular expressions h1
Regular expressions h1
 
Cfg part i
Cfg   part iCfg   part i
Cfg part i
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 

More from ahmad haidaroh

Materi 7 Context Free Grammar
Materi 7   Context Free Grammar Materi 7   Context Free Grammar
Materi 7 Context Free Grammar ahmad haidaroh
 
Materi 3 Finite State Automata
Materi 3   Finite State AutomataMateri 3   Finite State Automata
Materi 3 Finite State Automataahmad haidaroh
 
Materi 3 Finite State Automata
Materi 3   Finite State AutomataMateri 3   Finite State Automata
Materi 3 Finite State Automataahmad haidaroh
 
Pertemuan 4 Aljabar Boole
Pertemuan 4   Aljabar Boole Pertemuan 4   Aljabar Boole
Pertemuan 4 Aljabar Boole ahmad haidaroh
 
Pertemuan 2&3 - Dasar2 Keamanan Encyption
Pertemuan 2&3 - Dasar2 Keamanan EncyptionPertemuan 2&3 - Dasar2 Keamanan Encyption
Pertemuan 2&3 - Dasar2 Keamanan Encyptionahmad haidaroh
 
Multiplekser - Demultiplekser - Pertemuan 7
Multiplekser - Demultiplekser - Pertemuan 7Multiplekser - Demultiplekser - Pertemuan 7
Multiplekser - Demultiplekser - Pertemuan 7ahmad haidaroh
 
Pertemuan 3a Rangkaian Aritmatik-Half n Full Adder
Pertemuan 3a   Rangkaian Aritmatik-Half n Full AdderPertemuan 3a   Rangkaian Aritmatik-Half n Full Adder
Pertemuan 3a Rangkaian Aritmatik-Half n Full Adderahmad haidaroh
 
Pertemuan 6 Penyederhanaan RL-Karnaugh Map
Pertemuan 6   Penyederhanaan RL-Karnaugh MapPertemuan 6   Penyederhanaan RL-Karnaugh Map
Pertemuan 6 Penyederhanaan RL-Karnaugh Mapahmad haidaroh
 
Pertemuan 5a gerbang kombinasi-maxtem-minterm
Pertemuan 5a   gerbang kombinasi-maxtem-mintermPertemuan 5a   gerbang kombinasi-maxtem-minterm
Pertemuan 5a gerbang kombinasi-maxtem-mintermahmad haidaroh
 
Pertemuan 5 gerbang logika dasar n bentukan
Pertemuan 5   gerbang logika dasar n bentukanPertemuan 5   gerbang logika dasar n bentukan
Pertemuan 5 gerbang logika dasar n bentukanahmad haidaroh
 
Aritmatika Biner - Pertemuan 3
Aritmatika Biner - Pertemuan 3Aritmatika Biner - Pertemuan 3
Aritmatika Biner - Pertemuan 3ahmad haidaroh
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilanganahmad haidaroh
 

More from ahmad haidaroh (20)

Materi 7 Context Free Grammar
Materi 7   Context Free Grammar Materi 7   Context Free Grammar
Materi 7 Context Free Grammar
 
8 Rekursif
8 Rekursif8 Rekursif
8 Rekursif
 
6 ANTRIAN - QUEUE
6 ANTRIAN - QUEUE6 ANTRIAN - QUEUE
6 ANTRIAN - QUEUE
 
5 STACK
5 STACK5 STACK
5 STACK
 
4 Adt
4 Adt4 Adt
4 Adt
 
3 Linked List
3   Linked List3   Linked List
3 Linked List
 
2 Array
2 Array2 Array
2 Array
 
Materi 3 Finite State Automata
Materi 3   Finite State AutomataMateri 3   Finite State Automata
Materi 3 Finite State Automata
 
Materi 3 Finite State Automata
Materi 3   Finite State AutomataMateri 3   Finite State Automata
Materi 3 Finite State Automata
 
Presentasi OSPEK 2018
Presentasi OSPEK 2018Presentasi OSPEK 2018
Presentasi OSPEK 2018
 
Pertemuan 4 Dioda1
Pertemuan 4   Dioda1Pertemuan 4   Dioda1
Pertemuan 4 Dioda1
 
Pertemuan 4 Aljabar Boole
Pertemuan 4   Aljabar Boole Pertemuan 4   Aljabar Boole
Pertemuan 4 Aljabar Boole
 
Pertemuan 2&3 - Dasar2 Keamanan Encyption
Pertemuan 2&3 - Dasar2 Keamanan EncyptionPertemuan 2&3 - Dasar2 Keamanan Encyption
Pertemuan 2&3 - Dasar2 Keamanan Encyption
 
Multiplekser - Demultiplekser - Pertemuan 7
Multiplekser - Demultiplekser - Pertemuan 7Multiplekser - Demultiplekser - Pertemuan 7
Multiplekser - Demultiplekser - Pertemuan 7
 
Pertemuan 3a Rangkaian Aritmatik-Half n Full Adder
Pertemuan 3a   Rangkaian Aritmatik-Half n Full AdderPertemuan 3a   Rangkaian Aritmatik-Half n Full Adder
Pertemuan 3a Rangkaian Aritmatik-Half n Full Adder
 
Pertemuan 6 Penyederhanaan RL-Karnaugh Map
Pertemuan 6   Penyederhanaan RL-Karnaugh MapPertemuan 6   Penyederhanaan RL-Karnaugh Map
Pertemuan 6 Penyederhanaan RL-Karnaugh Map
 
Pertemuan 5a gerbang kombinasi-maxtem-minterm
Pertemuan 5a   gerbang kombinasi-maxtem-mintermPertemuan 5a   gerbang kombinasi-maxtem-minterm
Pertemuan 5a gerbang kombinasi-maxtem-minterm
 
Pertemuan 5 gerbang logika dasar n bentukan
Pertemuan 5   gerbang logika dasar n bentukanPertemuan 5   gerbang logika dasar n bentukan
Pertemuan 5 gerbang logika dasar n bentukan
 
Aritmatika Biner - Pertemuan 3
Aritmatika Biner - Pertemuan 3Aritmatika Biner - Pertemuan 3
Aritmatika Biner - Pertemuan 3
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilangan
 

Recently uploaded

How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 

Recently uploaded (20)

How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 

Materi 4 Regular Expression

  • 1. REGEX (REGULAR EXPRESSION) STIKOM Artha Buana Teknik Informatika 2014 Ir. Ahmad Haidaroh, M.Kom.
  • 2. Regular expressions • FSA (NFSA atau DFSA) merupakan cetak biru (blueprint) untuk membuat suatu mesin yang dapat mengenali regular language (RL). • Regex merupakan cara pendeklarasian RL yang ramah pengguna (user-friendly). • Contoh: 01* + 10* - 2 STIKOM Artha Buana
  • 3. Regular expressions • Regex digunakan, misalnya pada: • Perintah grep UNIX • Tools Lex (Lexical analyzer generator) dan Flex (Fast Lex) UNIX - 3 STIKOM Artha Buana
  • 4. • Regular Language Finite Automata • Regular Language  Regular Expressions • Finite Automata  Regular Expressions - 4 STIKOM Artha Buana
  • 5. • Regular Language Finite Automata • Regular Language  Regular Expressions • Finite Automata  Regular Expressions - 5 STIKOM Artha Buana
  • 6. • Regular Language Finite Automata • Regular Language  Regular Expressions • Finite Automata  Regular Expressions - 6 STIKOM Artha Buana
  • 7. Review (Operasi Bahasa) • Gabungan (Union) L  M = {w | w  L atau w  M} • Sambungan (Konkatenasi) LM = {w | w = xy, x  L atau y  M} • Pangkat L0 = {}, L1= L, Lk+1= LLk • Klosur L* = 𝑖=0 ∞ 𝐿𝑖 - 7 STIKOM Artha Buana x = 01101 dan y = 110 Maka xy = 01101110 dan yx = 11001101 Jika L = {001, 10, 111} dan M = {, 001} maka L.M = {001, 10, 111, 001001, 10001, 111001}
  • 8. Regular Language Regular Language & Regular Expressions Contoh 1: r = (a + b.c)* L(r) = {a,bc}* L(r) = {, a, bc, aa, abc, bca, …} - 8 STIKOM Artha Buana Regular Expressions
  • 9. Regular Language & Regular Expressions Contoh 2: r = (a + b)*(a + bb) L(r) = {a, bb, aa, abb, ba, bbb, …} - 9 STIKOM Artha Buana
  • 10. Regular Language & Regular Expressions Contoh 3: r = (aa)*(bb)*b L(r) = {a2nb2mb | n,m ≥ 1} - 10 STIKOM Artha Buana
  • 11. Regular Language & Regular Expressions Contoh 4: r = (aa)*(bb)*b L(r) = {a2nb2mb | n,m ≥ 0} - 11 STIKOM Artha Buana
  • 12. Regular Language & Regular Expressions Contoh 5: r = (0+1)*00(0+1)* L(r) = {semua string yang memiliki sekurangnya dua 0 berurutan} - 12 STIKOM Artha Buana
  • 13. Regular Language & Regular Expressions Contoh 6: r = (1+01)*(0+) L(r) = {semua string tanpa dua 0 berurutan} ) 0 ( * ) 01 1 (     r - 13 STIKOM Artha Buana
  • 14. • Regular Language Finite Automata • Regular Language  Regular Expressions • Finite Automata  Regular Expressions - 14 STIKOM Artha Buana
  • 15. KONVERSI dr DFSA  RE Contoh 1: • Buatlah RE dari DFSA berikut • Konversikan dalam bentuk RE - 15 STIKOM Artha Buana
  • 16. • Eliminasi Keadaan 1, menjadi: • Konversi dalam bentuk RE - 16 STIKOM Artha Buana KONVERSI dr DFSA  RE
  • 17. • RE dari DFSA : (0+10)*11(0+1)* • Eliminasi Keadaan 1 - 17 STIKOM Artha Buana Ingat ! : State Input dan Output harus selalu ada KONVERSI dr DFSA  RE
  • 18. Contoh 2: • Buatlah RE dari DFSA yang dapat menerima 1 berjumlah genap • Eliminasi Keadaan 2, menjadi - 18 STIKOM Artha Buana 0+10*1 KONVERSI dr DFSA  RE
  • 19. • Dua keadaan akhir, matikan Keadaan 3 dahulu! • Hasilnya 0* karena yang menuju Keadaan 3 tidak akan diterima FSA (seharusnya finish di 3) - 19 STIKOM Artha Buana 0+10*1 KONVERSI dr DFSA  RE
  • 20. • Selanjutnya, matikan Keadaan 1! • Hasilnya (10*1(0+10*1) - 20 STIKOM Artha Buana KONVERSI dr DFSA  RE
  • 21. • Dikombinasikan dengan hasil sebelumnya, menjadi: (0*+10*1(0+10*1) - 21 STIKOM Artha Buana KONVERSI dr DFSA  RE