-1

I have one variable having value

ServerC = "WebSphere:cell=abc,cluster=Cluster1+WebSphere:cell=abc,cluster=Cluster2"

I want only all Cluster values in another variable I am trying to use

clusterN = ServerC.split("cluster=")
clusterN = clusterN[1]

but I am not getting required values

3
  • what do you mean by U&L Commented Dec 28, 2016 at 21:46
  • This is related to Python Scripting in Linux Commented Dec 28, 2016 at 21:56
  • "but I am not getting required values". What are you getting and what is it you want? Commented Dec 28, 2016 at 22:59

1 Answer 1

3

You can use re.findall():

import re
ServerC = "WebSphere:cell=abc,cluster=Cluster1+WebSphere:cell=abc,cluster=Cluster2"
pat = re.compile("cluster\=(\w+)")
print(pat.findall(ServerC))

# Output: ['Cluster1', 'Cluster2'] 
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.