mirror of
https://github.com/imjasonh/testscript-rs
synced 2026-07-12 10:58:27 +00:00
Add explicit Unicode mode to regex patterns for proper Unicode handling (#40)
This commit is contained in:
parent
2dfdbc818d
commit
d059265fa1
11 changed files with 40 additions and 4 deletions
|
|
@ -218,7 +218,14 @@ impl TestEnvironment {
|
|||
|
||||
/// Search for a pattern in files (like grep)
|
||||
pub fn grep_files(&mut self, pattern: &str, files: &[String]) -> Result<()> {
|
||||
let regex = Regex::new(pattern)
|
||||
// Enable Unicode mode for proper Unicode character matching in grep patterns
|
||||
let pattern_with_flags = if pattern.starts_with("(?") {
|
||||
// Pattern already has flags, don't add more
|
||||
pattern.to_string()
|
||||
} else {
|
||||
format!("(?u){}", pattern)
|
||||
};
|
||||
let regex = Regex::new(&pattern_with_flags)
|
||||
.map_err(|e| Error::command_error("grep", format!("Invalid regex: {}", e)))?;
|
||||
|
||||
let mut _found_matches = false;
|
||||
|
|
|
|||
|
|
@ -236,7 +236,9 @@ impl TestEnvironment {
|
|||
|| expected_substituted.contains('*')
|
||||
|| expected_substituted.contains('.')
|
||||
{
|
||||
let regex_pattern = format!("(?s){}", expected_substituted); // (?s) enables DOTALL mode
|
||||
// Enable DOTALL mode (?s) for . to match newlines
|
||||
// Enable Unicode mode (?u) for proper Unicode character matching
|
||||
let regex_pattern = format!("(?su){}", expected_substituted);
|
||||
let regex = Regex::new(®ex_pattern)
|
||||
.map_err(|e| Error::command_error(output_type, format!("Invalid regex: {}", e)))?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue