Linux shell domain regular expression matching, Chinese matching

Linux shell domain regular expression matching, Chinese matching

#common
^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})*$
echo "www.baidu.com " | egrep "^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})*$"

#Chinese
echo "测试.test.网址" |grep -P "^(?=^.{3,255}$)[a-zA-Z0-9\p{Han}][-a-zA-Z0-9\p{Han}]{0,62}(\.[a-zA-Z0-9\p{Han}][-a-zA-Z0-9\p{Han}]{0,62})+$"

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example