2016-12-28 5 views
-1

を使用して、特定のテキストを抽出するは、どのように私は1つの変数持つ価値を持っているのpython

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

私は

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

を使用しようとしています別の変数 で唯一、すべてのクラスタ値をしたいが、私はなっておりません必要な値

+0

U&Lとはどういう意味ですか? – Manish

+0

これはLinuxのPython Scriptingに関連しています。 – Manish

+0

"しかし、私は必要な値を取得していません"。あなたは何を手に入れていますか、それは何ですか? –

答えて

3

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

ありがとうドミトリーそれは働いた – Manish

関連する問題