1 / 21

Regex

Regex. Teknik Informatika STTA 2013. Yenni Astuti , S.T., M.Eng. Regular expressions. FSA (NFSA atau DFSA) merupakan cetak biru ( blueprint ) untuk membuat suatu mesin yang dapat mengenali regular language (RL).

rudolf
Download Presentation

Regex

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Regex TeknikInformatika STTA 2013 YenniAstuti, S.T., M.Eng.

  2. Regular expressions • FSA (NFSA atau DFSA) merupakancetakbiru (blueprint) untukmembuatsuatumesin yang dapatmengenaliregular language (RL). • Regex merupakancarapendeklarasian RL yang ramahpengguna (user-friendly). • Contoh: 01* + 10*

  3. Regular expressions • Regex digunakan, misalnyapada: • Perintahgrep UNIX • ToolsLex (Lexical analyzer generator) danFlex (Fast Lex) UNIX

  4. Regular Language Finite Automata • Regular Language  Regular Expressions • Finite Automata  Regular Expressions

  5. Regular Language Finite Automata • Regular Language  Regular Expressions • Finite Automata  Regular Expressions

  6. Regular Language Finite Automata • Regular Language  Regular Expressions • Finite Automata  Regular Expressions

  7. Review (OperasiBahasa) • Gabungan (Union) L  M = {w | w  L atauw  M} • Sambungan (Konkatenasi) LM = {w | w = xy, x  L atauy  M} • Pangkat L0 = {}, L1= L, Lk+1= LLk • Klosur L* =

  8. Regular Language & Regular Expressions Contoh 1: r = (a + b.c)* L(r) = {a,bc}* L(r) = {, a,bc, aa, abc, bca, …}

  9. Regular Language & Regular Expressions Contoh 2: r = (a + b)*(a + bb) L(r) = {a, bb, aa, abb, ba, bbb, …}

  10. Regular Language & Regular Expressions Contoh 3: r = (aa)*(bb)*b L(r) = {a2nb2mb | n,m≥ 0}

  11. Regular Language & Regular Expressions Contoh4: r = (aa)*(bb)*b L(r) = {a2nb2mb | n,m≥ 0}

  12. Regular Language & Regular Expressions Contoh 5: r = (0+1)*00(0+1)* L(r) = {semua string yang memilikisekurangnyadua 0 berurutan}

  13. Regular Language & Regular Expressions Contoh6: r = (1+01)*(0+)* L(r) = {semua string tanpadua 0 berurutan}

  14. Regular Language Finite Automata • Regular Language  Regular Expressions • Finite Automata  Regular Expressions

  15. DFSA & RE Contoh 1: • Buatlah RE dari DFSA berikut • Konversikandalambentuk RE

  16. DFSA & RE • EliminasiKeadaan 1, menjadi: • Konversidalambentuk RE

  17. DFSA & RE • RE dari DFSA : (0+10)*11(0+1)* • EliminasiKeadaan1

  18. DFSA & RE Contoh 2: • Buatlah RE dari DFSA yang dapatmenerima1 berjumlahgenap • EliminasiKeadaan 2, menjadi

  19. DFSA & RE • Duakeadaanakhir, matikanKeadaan 3 dahulu! • Hasilnya 0* karena yang menujuKeadaan 3 tidakakanditerima FSA

  20. DFSA & RE • Selanjutnya, matikanKeadaan 1! • Hasilnya 0*10*1(0+10*1)

  21. DFSA & RE • Dikombinasikandenganhasilsebelumnya, menjadi: 0*+0*10*1(0+10*1)

More Related