本帖最后由 aloha20200628 于 2025-4-1 15:36 编辑
回复 5# netdzb
以下代码存为 test.bat 运行... | @echo off &chcp 936>nul | | for %%s in ( | | "@#=www.cynidi.com" | | "中文测试字符串www.cynidi.com" | | "+*#abc123.xyz456.789def" | | ) do echo,%%s|sed -C -r "s/[^0-9\.a-z]|([\x81-\xFE][\x40-\xFE])//ig" | | pause&exit/bCOPY |
因 for %%s in (...) do 句式会自动匹配循环变量值中的 *? 通配符,故以上代码须订正如下... | @echo off &chcp 936>nul | | echo,"@#=www.cynidi.com"|sed -C -r "s/[^0-9\.a-z]|([\x81-\xFE][\x40-\xFE])//ig" | | echo,"中文测试字符串www.cynidi.com"|sed -C -r "s/[^0-9\.a-z]|([\x81-\xFE][\x40-\xFE])//ig" | | echo,"+*#abc123.xyz456.789def"|sed -C -r "s/[^0-9\.a-z]|([\x81-\xFE][\x40-\xFE])//ig" | | pause&exit/bCOPY |
|