文章标题
来源:互联网 发布:在淘宝买了劣质产品 编辑:程序博客网 时间:2024/06/16 08:41
一、判断读取字符串值
表达式 含义
二、字符串操作(长度,读取,替换)
|{#string}|string的长度
|
|
|{string#substring}|从变量string的开头, 删除最短匹配
|{string%substring}|从变量string的结尾, 删除最短匹配
|
|{string/#substring/replacement}|如果string的前缀匹配
说明:”* $substring”可以是一个正则表达式.
1.长度
[web97@salewell97 ~]
12
${#变量名}得到字符串长度
2.截取字串
[chengmo@localhost ~]
e china
${变量名:起始:长度}得到子字符串
3.字符串删除
[chengmo@localhost ~]
c:/windows/boot.ini
[chengmo@localhost ~] echo {test#*/}
windows/boot.ini
[chengmo@localhost ~] echo ${test##*/}
boot.ini
[chengmo@localhost ~]
c:/windows
[chengmo@localhost ~]
${变量名#substring正则表达式}从字符串开头开始配备substring,删除匹配上的表达式。
${变量名%substring正则表达式}从字符串结尾开始配备substring,删除匹配上的表达式。
注意:{test##*/},{test%/*} 分别是得到文件名,或者目录地址最简单方法。
4.字符串替换
[chengmo@localhost ~]
c:\windows/boot.ini
[chengmo@localhost ~] echo ${test//\//\}
c:\windows\boot.ini
${变量/查找/替换值} 一个“/”表示替换第一个,”//”表示替换所有,当查找中出现了:”/”请加转义符”\/”表示。
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- Hadoop系列-MapReduce编程入门案例(八)
- win10下MATLAB figure 中文乱码
- Java机器学习库ML之九交叉验证法(Cross Validation)
- ssh hibernate 获取sql列名
- SpringBoot 返回Json
- 文章标题
- Yii2之cache的使用
- linux查看和修改PATH环境变量的几种方法
- MD5 使用 md5sum hash 校验文件完整性与是否被篡改
- 面试题 3:二维数组中的查找
- java 发送邮件
- SSM三大框架整合详细教程(Spring+SpringMVC+MyBatis
- linux系统编程之信号(一):中断与信号
- android写数据到手机内存