I'm using system.tag.getConfiguration() to get the expression out of an expression tag. From this, I want to extract a list of all the tags referenced in the expression. For example, if the expression is
I was hoping to find a script function that would search a string using regex to find a substring match, but I'm not seeing anything comparable to the IndexOf expression function.
I find that it's easier if you include the delimiters, that way you can eliminate any expressions that might be between tags.
I assume from your expected output that you were wanting a set, which would eliminate duplicate tag entries. A list could just as easily be used.
There is a java.util.StringTokenizer which will do this same thing, however, that has been deprecated. The recommended method is now String.split()
from java.lang import String
test = "{[.]../FolderA/Tag1}||{[.]../Tag2}||{[.]../FolderB/FolderC/Tag3}"
tokens = String(test).split("((?=\{|\})|(?<=\{|\}))")
tags = set()
enumToken = enumerate(tokens)
for cursor,token in enumToken:
if token == "{":
#start of tag path, consume the token
cursor,token = next(enumToken)
tags.add(token)
#consume the ending brace
cursor,token = next(enumToken)
print tags