利用你学过的知识点,想办法根据要求截取出字符。
字符串var= http://www.aaa.com/root/123.htm
- 取出 www.aaa.com/root/123.htm
- 取出123.htm
- 取出 http://www.aaa.com/root
- 取出http:
- 取出http://
- 取出root/123.htm
- 取出123
核心要点
grep -o 只匹配关键字的字符grep -P 支持perl模式 包括非贪婪匹配的正则 {m,n}? {m,}? ?? *? +?grep -E/egrep 支持扩展正则 有 + ? | {}和() 不需要转义
sed/awk
代码内容
1 |
|