Skip to content

Commit

Permalink
Fix incorrect format when leading with letter or number. #21
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Apr 11, 2022
1 parent efebac4 commit 7ac0d4b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions autocorrect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ lazy_static! {
// Strategies all rules
static ref STRATEGIES: Vec<Strategery> = vec![
// EnglishLetter, Number
// But not start with %, $, \ for avoid change %s, %d, $1, $2, \1, \2, \d, \r, \p ... in source code
// Avoid add space when Letter, Number has %, $, \ prefix, eg. %s, %d, $1, $2, \1, \2, \d, \r, \p ... in source code
Strategery::new(r"\p{CJK}[^%\$\\]", r"[a-zA-Z0-9]"),
Strategery::new(r"[a-zA-Z0-9]", r"\p{CJK}"),
Strategery::new(r"[^%\$\\][a-zA-Z0-9]", r"\p{CJK}"),
// Spcial format Letter, Number leading case, because the before Strategery can't cover eg. A开头的case测试
Strategery::new(r"^[a-zA-Z0-9]", r"\p{CJK}"),
// 10%中文
Strategery::new(r"[0-9][%]", r"\p{CJK}"),
// SpecialSymbol
Expand Down

0 comments on commit 7ac0d4b

Please sign in to comment.