shell 里的正则
2024-08-31 20:44:08
#!/bin/bash variable="This is a fine mess." echo "$variable" # Regex matching with =~ operator within [[ double brackets ]].
if [[ "$variable" =~ T.........fin*es* ]]
# NOTE: 从bash V3.2开始,正则表达式不再用引号引起来
then
echo "match found"
# match found
fi
#!/bin/bash input=$ if [[ "$input" =~ "[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]" ]]
# ^ NOTE: Quoting not necessary, as of version 3.2 of Bash.
# NNN-NN-NNNN (where each N is a digit).
then
echo "Social Security number."
# Process SSN.
else
echo "Not a Social Security number!"
# Or, ask for corrected input.
fi
最新文章
- FreeMarker:怎么使用
- [Python] 网络爬虫和正则表达式学习总结
- 保利威视Polyv点播集成
- Controlling z-order using the ZIndex Property
- 手绘经典QQ头像 请让我一个人呆一会
- python小记列表排序
- 仿中关村win8频道(win8.zol.com.cn)下的tab效果
- .net后台获取DataTable数据,转换成json数组后传递到前台,通过jquery去操作json数据
- ansj人名识别
- 第26月第18天 mybatis_spring_mvc
- VC++ 字符串Dword、LPSTR、LPWSTR、LPCSTR、LPCWSTR、LPTSTR、LPCTSTR
- dell 远程管理卡的使用racadm
- Fabric密码保存
- sourcetree向github推送代码提示密码错误
- CentOS7.3下的一个iptables配置
- docker centos:latest 使用 sshd
- 客户端和服务端如何使用Token和Session
- webpack Error: Cannot find module 'webpack/lib/Chunk' Extract-text-webpack-plugin 分离CSS
- jquery hide和show方法
- 【深入理解JAVA虚拟机】第5部分.高效并发.1.Java内存模型与线程。
热门文章
- Scala学习十六——XML处理
- CF336C-Vasily the Bear and Sequence题解--贪心
- python matplotlib 折线图
- C#/.net 通过js调用系统相机进行拍照,图片无损压缩后进行二维码识别
- PropertiesUtils(普遍做法)
- 2.4 使用 xpath 对xml 进行解析
- 工作总结 页面 ActionResult / JsonResult 将对象以 Json() 返回
- C++中volatile
- 制作docker 离线仓库
- 02 js原型链