如何在管道中的字符串中的特殊字符后获取数值 [英] how to get numeric values after special character in a string in pipeline

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

问题描述

在我的管道中,我有一个变量"abd",其值为"xyz #123". 我只需要在特殊字符#之后获取数字值, 如何在Jenkins Pipeline中实现这一目标?

In my pipeline I have a variable abd with value "xyz #123". I need to get only numeric value after special character #, How do I achieve this in Jenkins Pipeline?

推荐答案

您可以在Groovy中非常简单地执行此操作(如果您的字符串始终与该模式匹配):

You can do this in Groovy fairly simply (if your string always matches that pattern):

abc.substring(abc.indexOf('#') + 1, abc.length())

这将为您提供字符串123.

That will give you the string 123.

这篇关于如何在管道中的字符串中的特殊字符后获取数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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