简体   繁体   English

它在bash中是什么意思?

[英]What does it line mean in bash?

spkgender=$(perl -ane ' s/.*gender\\:\\W*(.).*/lc($1)/ei && print; ' <$rdm)

It is regex and it extracts M from 'Gender: Male', but it doesn't work for unicode. 它是正则表达式,它从“性别:男性”中提取M ,但不适用于unicode。

How to make it work with unicode? 如何使其与unicode一起使用?

It doesn't work for 'Gender: Мужской' - looks like \\W "eats" all unicode symbols. 它不适用于“性别:Мужской”-看起来\\W “吃掉了”所有unicode符号。

Use /u regex modifier. 使用/u regex修饰符。 Source: https://perldoc.perl.org/perlre.html 资料来源: https : //perldoc.perl.org/perlre.html

spkgender=$(perl -ane ' s/.*gender\:\W*(.).*/lc($1)/uei && print; ' <$rdm)

Alternately, use the official POSIX character class. 或者,使用官方的POSIX字符类。 instead of \\W use [[:blank:]] . 代替\\W使用[[:blank:]] As far as I know it supports Unicode. 据我所知,它支持Unicode。

Also, please make sure you are using Unicode correctly in general. 另外,请确保总体上正确使用Unicode。 Reference: https://perldoc.perl.org/perlunicode.html 参考: https : //perldoc.perl.org/perlunicode.html

When the string has come from an external source marked as Unicode 当字符串来自标记为Unicode的外部来源时
The -C command line option can specify that certain inputs to the program are Unicode, and the values of this can be read by your Perl code, see ${^UNICODE} in perlvar. -C命令行选项可以指定程序的某些输入是Unicode,并且此值可以由您的Perl代码读取,请参阅perlvar中的$ {^ UNICODE}。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM