正则表达式从开始/结束模式中提取字符串

时间:2017-09-11 08:28:52

标签: regex

我想从输入字符串“some_file_name_V_1_0.xml”中提取字符串“1_0”

我应该用什么正则表达式做到这一点?

I was think of extracting the string 1_0 that is between :
- The begin pattern "_V_"
- The end pattern ".xml"

输入中的toto_V_2_0.xml应该返回2_0

感谢您的帮助,

此致

1 个答案:

答案 0 :(得分:1)

尝试使用以下模式:

^.*?V_(.*)\.xml$

然后检查第一个捕获组的版本字符串。

相关问题