| Crates.io | oak-regex |
| lib.rs | oak-regex |
| version | 0.0.1 |
| created_at | 2025-10-21 12:33:12.645877+00 |
| updated_at | 2026-01-23 05:18:05.563598+00 |
| description | High-performance incremental regular expression parser for the oak ecosystem with flexible configuration, optimized for pattern matching and text processing. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1893744 |
| size | 143,183 |
High-performance incremental regular expression parser for the oak ecosystem with flexible configuration, optimized for pattern matching and text processing.
Oak Regex is a robust parser for regular expressions, designed to handle complete regex syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for pattern matching and text processing.
Basic example:
use oak_regex::{Parser, RegexLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
"#);
let result = parser.parse(&source);
println!("Parsed regex successfully.");
Ok(())
}
use oak_regex::{Parser, RegexLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
"#);
let result = parser.parse(&source);
println!("Email pattern parsed successfully.");
use oak_regex::{Parser, RegexLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
(?:(?<=\s)|^)(?:https?:\/\/)?(?:www\.)?[a-zA-Z0-9-]+\.[a-zA-Z]{2,}(?:\/\S*)?(?=\s|$)
"#);
let result = parser.parse(&source);
println!("URL pattern parsed successfully.");
use oak_regex::{Parser, RegexLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
(?:cat|dog|bird)(?:\s+(?:is|are)\s+(?:brown|black|white))?
"#);
let result = parser.parse(&source);
println!("Group and alternation parsed successfully.");
use oak_regex::{Parser, RegexLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"\d{3}-\d{2}-\d{4}"#);
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_regex::{Parser, RegexLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
// Unclosed character class
[a-z
"#);
let result = parser.parse(&source);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak Regex integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.