Skip to content

ryota2357/dfa-regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dfa-regex

Simple DFA Regex engine wirrten in Rust.

Example

#[test]
fn case01() {
    let regex = Regex::new(r"(p(erl|ython|hp)|ruby)").unwrap();
    assert!(regex.matches("python"));
    assert!(regex.matches("ruby"));
    assert!(regex.matches("perl"));
    assert!(!regex.matches("ruby2"));
    assert!(!regex.matches("java"));
    assert!(!regex.matches("VB"));
}

For more examples, please see tests/matches.rs

Supported Features

You can use Unicode characters such as a, A, .

  • \: Escape character. e.g. \( \+
  • |: OR operator. e.g. a|b
  • *: Repeat more than 0. e.g. a*
  • +: Repeat more than 1. e.g. a+
  • ( and ): e.g. a(b|c)*