import re
value = "world_wide='test1/one/two', " \
"stage_test='ALPHA', world_wide='test2/one/two', " \
"stage_test='GAMMA', world_wide='test3/one/two', " \
"stage_test='GAMMA', world_wide='test4/one/two', " \
"stage_test='ALPHA', world_wide='test5/one/two', " \
"stage_test='GAMMA', world_wide='test6/one/two', " \
"stage_test='GAMMA"
pattern = r"(world_wide=\'.*\')"
for match in re.findall(pattern, str(value)):
print ("\n", match)
Trying to filter for a specific output given a string value. With the code above the following output is given:
world_wide='test1/one/two', stage_test='ALPHA', world_wide='test2/one/two', stage_test='GAMMA', world_wide='test3/one/two', stage_test='GAMMA', world_wide='test4/one/two', stage_test='ALPHA', world_wide='test5/one/two', stage_test='GAMMA', world_wide='test6/one/two', stage_test='
What I'm trying to get is: if the string matches a specific condition such as:
if 'world_wide=' is found, return the following value between the two characters. In this case, this would be two single quotes excluding the '/one/two'.
Desired output:
>>>test1
test2
test3
test4
.........
valueis more readable? It seems like you have a quote closing problem in your post.