获取特定的字符串 [英] Get specific string

查看:94
本文介绍了获取特定的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一个更大的字符串获取特定的字符串:

I need to get a specific string from a bigger string:

从这些 Abcd1234_Tot9012_tore.dr Abcd1234_Tot9012.tore.dr

我要得到那些托特之间的数字_ ,所以我应该得到 9012 。重要的是,前和这些数字后的字符数可以变化。

I want to get those numbers which are between Tot and _ or . , so I should get 9012. Important thing is that the number of characters before and after these numbers may vary.

谁能给我提供了很好的解决方案?在此先感谢!

Could anyone give me a nice solution for this? Thanks in advance!

推荐答案

这也应该,如果你正在寻找只为托特后的数字工作

This should also work if you are looking only for numbers after Tot

[srikanth@myhost ~]$ echo "Abcd1234_Tot9012_tore.dr" | awk ' { match($0,/Tot([0-9]*)/,a); print a[1]; } '
9012
[srikanth@myhost ~]$ echo "Abcd1234_Tot9012.tore.dr" | awk ' { match($0,/Tot([0-9]*)/,a); print a[1]; } '
9012

这篇关于获取特定的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆