File tree Expand file tree Collapse file tree 3 files changed +6
-2
lines changed
Expand file tree Collapse file tree 3 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,5 @@ version = "0.1.0"
44edition = " 2021"
55
66[dependencies ]
7- ib-pinyin = " 0.2.5"
7+ ib-pinyin = " 0.2.5"
8+ regex = " 1.11.1"
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments