检查字符串中是否存在表情符号[BASH]

时间:2017-12-07 10:57:36

标签: regex bash emoji

我试图弄清楚字符串中是否存在一个表情符号作为Bash 4.3.11中的子字符串

Process child:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/multiprocessing/managers.py", line 749, in _callmethod
AttributeError: 'ForkAwareLocal' object has no attribute 'connection'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
  File "/usr/local/lib/python3.6/multiprocessing/process.py", line 93, in run
  File "/home/eri/Projects/server/child.py", line 215, in setup_loop
  File "/home/eri/Projects/server/child.py", line 164, in setup_clients
  File "<string>", line 2, in append
  File "/usr/local/lib/python3.6/multiprocessing/managers.py", line 753, in _callmethod
  File "/usr/local/lib/python3.6/multiprocessing/managers.py", line 740, in _connect
  File "/usr/local/lib/python3.6/multiprocessing/connection.py", line 487, in Client
  File "/usr/local/lib/python3.6/multiprocessing/connection.py", line 614, in SocketClient
FileNotFoundError: [Errno 2] No such file or directory

这似乎不起作用。

1 个答案:

答案 0 :(得分:0)

尝试使用模式匹配,将代码点编码为utf-8字节:

emoji=$'\xed[\xa0-\xaf][\x80-\xbf]'
[[ "..." = *$emoji* ]] && echo found