Skip to main content

Posts

Showing posts with the label simple

Simple Java Regular Expression Implementation

Introduction Regular Expressions is an amazing tool that makes our lives easier. The power it gives is well perceived thus it is supported by many programming and scripting languages. Power of regular expressions comes from another great mathematical tool: deterministic or non-deterministic finite automata. NFA/DFA is an interesting topic covered in Formal Languages and Automata Theory lectures which is supposed to be taken by all Computer Science graduates. This article covers a simple NFA implementation of regular expressions.  Thompson NFA algorithm , which is referenced in  Regular Expression Matching Can Be Simple and Fast  article, is used in implementation. Implementation Grammar Implementation uses the following  Backus-Naur Form  grammar which is a subset of the grammar presented in  A Grammar for Regular Expressions . <regex>          ::=  <simple-regex>  |...