Linux grep正则匹配各国语言

The Unicode standard places each assigned code point (character) into one script. A script is a group of code points used by a particular human writing system. Some scripts like Thai correspond with a single human language. Other scripts like Latin span multiple languages.

Some languages are composed of multiple scripts. There is no Japanese Unicode script. Instead, Unicode offers the Hiragana, Katakana, Han, and Latin scripts that Japanese documents are usually composed of.

A special script is the Common script. This script contains all sorts of characters that are common to a wide range of scripts. It includes all sorts of punctuation, whitespace and miscellaneous symbols.

All assigned Unicode code points (those matched by \P{Cn}) are part of exactly one Unicode script. All unassigned Unicode code points (those matched by \p{Cn}) are not part of any Unicode script at all.

The JGsoft enginePerlPCREPHPRuby 1.9Delphi, and XRegExp can match Unicode scripts. Here’s a list:

1. 匹配中文

grep -P '[\p{Han}]'  test.log

 2. 匹配其他国家语言

\p{Common} \p{Arabic} \p{Armenian} \p{Bengali} \p{Bopomofo} 
\p{Braille} \p{Buhid} \p{Canadian_Aboriginal} \p{Cherokee} 
\p{Cyrillic} \p{Devanagari} \p{Ethiopic} \p{Georgian} \p{Greek} 
\p{Gujarati} \p{Gurmukhi} \p{Han} \p{Hangul} \p{Hanunoo} \p{Hebrew} 
\p{Hiragana} \p{Inherited} \p{Kannada} \p{Katakana} \p{Khmer} \p{Lao} 
\p{Latin} \p{Limbu} \p{Malayalam} \p{Mongolian} \p{Myanmar} \p{Ogham} 
\p{Oriya} \p{Runic} \p{Sinhala} \p{Syriac} \p{Tagalog} \p{Tagbanwa} 
\p{TaiLe} \p{Tamil} \p{Telugu} \p{Thaana} \p{Thai} \p{Tibetan} 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: 在Linux中,grep命令可以用于在文件中搜索匹配某个正则表达式的文本。下面是一些关于grep和正则表达式的常见用法: 1. 使用`.`表示任意一个字符。例如,`grep '.' a.txt`将匹配包含任意一个字符的字符串。\[1\] 2. 使用`|`表示逻辑或操作符。例如,`grep 'fatal\|error\|critical' /var/log/nginx/error.log`将匹配包含单词"fatal"、"error"或"critical"的行。\[2\] 3. 使用`*`表示零次或多次匹配前面的字符或子表达式。例如,`grep 'se*' a.txt`将匹配包含以"s"开头,后面跟着零个或多个"e"的字符串,如"s"、"se"、"see"等。\[3\] 这些是grep和正则表达式的一些基本用法,你可以根据具体的需求进行进一步的学习和使用。 #### 引用[.reference_title] - *1* *3* [Linux grep 正则表达式](https://blog.csdn.net/panguangyuu/article/details/105033383)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Linux Grep 正则表达式](https://blog.csdn.net/ZauberC/article/details/130629591)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值