I will get Nexus artifact information in Array of Strings with full URL path. I need to display only JAR file name so I would like do regex on Array of Strings . Need Help on this ?
Could you elaborate a little more how this array is displayed?
But other than that, If you have a String[] object you can use javascript action to do what you want.
I don't know if your question relates on the regexp to be used. If that's the case, try this
\w+.jar
Shown here Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript
the Action below gives 124 artifacts in the nexus repository. I am getting these in string[] ( String Array) parameter.
Nexus - List Artifacts In a RepositoryFound 124 artifacts:http://localnexus.nexus.com/nexus/service/local/repositories/my-broker/content/com/nexus/mybroker/apple-server/243-master-c33b902-20160602-211202/apple-server-243-master-c33b902-20160602-211202.jarhttp://localnexus.nexus.com/nexus/service/local/repositories/my-broker/content/com/nexus/mybroker/apple-server/251-master-1e71194-20160604-000712/apple-server-251-master-1e71194-20160604-000712.jarhttp://localnexus.nexus.com/nexus/service/local/repositories/my-broker/content/com/nexus/mybroker/apple-server/252-master-f395a10-20160604-000859/apple-server-252-master-f395a10-20160604-000859.jarhttp://localnexus.nexus.com/nexus/service/local/repositories/my-broker/content/com/nexus/mybroker/apple-server/247-master-3b7cf89-20160603-225614/apple-server-247-master-3b7cf89-20160603-225614.jar
In next action I need to display only below as a User Input instead of above full URL link. This is possible when regex applied on this string array. But Build Regular Expression Action only can take String as a Input not a Array of Strings.
243-master-c33b902-20160602-211202251-master-1e71194-20160604-000712252-master-f395a10-20160604-000859247-master-3b7cf89-20160603-225614
Hello,
You can loop on the array and get access to each string in the array that way. Or you could pass the array to the JavaScript action and iterate through the array that way.
Cheers,
Gregg
So, as I said, you use the javascript action (Javascript - CA Release Automation - Integrations - CA Technologies Documentation ).
Something like this (I don't have access to RA right now, but it's something like this)
for (var i = 0; i < arrInput1.length; i++) { arrOutput1[i] = arrInput1[i].replace(/(\w|-)+(?=(.jar))/g, '') ;}
You can see the regexp working with your examples here
Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript
Hi Marcel,
Can you help me on how to give this script code ? Directly in value of Scrtipt (Input Name) ?
Regards
Mohanraj
Add this action to your flow
the script field is the one on my other answer
The ArrayInput1 is your Array and
In the ArrayOutput1 you can create another array name or use the same one I guess. Your choice.
Hi Mohanraj,
I'm including some links to some knowledge base articles we have that provide additional examples of how the "Execute Javascript code" action can be used - just in case they are helpful to you.
Split Strings Into Array With Execute JavaScript regex
Removing empty elements from Array Using Execute JavaScript action
How do I Convert a String Array Parameter to String Parameter
Kind regards,