mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
expr: Simplify parsing special cases for $
in regex
This commit is contained in:
parent
2a862bc385
commit
ab5cf74185
1 changed files with 2 additions and 8 deletions
|
@ -185,14 +185,8 @@ impl StringOp {
|
|||
| ('\\', false) => re_string.push(curr),
|
||||
_ => re_string.push_str(r"\^"),
|
||||
},
|
||||
'$' => {
|
||||
if is_end_of_expression(&pattern_chars) {
|
||||
re_string.push(curr);
|
||||
} else if !curr_is_escaped {
|
||||
re_string.push_str(r"\$");
|
||||
} else {
|
||||
re_string.push(curr);
|
||||
}
|
||||
'$' if !curr_is_escaped && !is_end_of_expression(&pattern_chars) => {
|
||||
re_string.push_str(r"\$");
|
||||
}
|
||||
'\\' if !curr_is_escaped && pattern_chars.peek().is_none() => {
|
||||
return Err(ExprError::TrailingBackslash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue