Skip to content

Commit ca78249

Browse files
committed
enh: ignore filename without a single han
Signed-off-by: wxiwnd <wxiwnd@outlook.com>
1 parent 85bc77a commit ca78249

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
ib-pinyin = "0.2.5"
7+
ib-pinyin = "0.2.5"
8+
regex = "1.11.1"

src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ fn main() {
1313
.pinyin_notations(PinyinNotation::Ascii | PinyinNotation::AsciiFirstLetter)
1414
.build();
1515

16+
let han_re = regex::Regex::new(r"\p{Han}").unwrap();
17+
1618
let mut results: Vec<String> = Vec::new();
1719
// Read current location
1820
if let Ok(entries) = std::fs::read_dir(".") {
1921
for entry in entries.flatten() {
2022
let path = entry.path();
2123
if let Some(file_name) = path.file_name() {
2224
if let Some(file_name_str) = file_name.to_str() {
23-
if matcher.is_match(file_name_str) {
25+
if matcher.is_match(file_name_str) && han_re.is_match(file_name_str) {
2426
results.push(file_name_str.to_string());
2527
}
2628
}

0 commit comments

Comments
 (0)