How to Extract color out of HTML text in Tag

I have a string tag in UDT which consist HTML value of color as below:
image

image

Is there any way to extract this color as I want to use this to fill background of label on vision screen.

Thanks so much,
Kaushik

Using a regex can do this for you.

def getHtmlColor(testString):
	import re

	regex = "<font color=(.{,})>"
	match = re.search(regex, testString)
	if match:
		return match.groups()[0][1:-1]
	else:
		return None

print  getHtmlColor("<html><font color='blue'>1.55")

Output:

blue

@JordanCClark thanks. Although, I was looking for an inbuilt function, this worked great.

It could be done in an expression.

split({[~]path/to/tag}, "['"+'"]')[1,0]
1 Like

I would not rely on this HTML coloring to work in the tag browser (as in, it’s absolutely a bug that it works at all). Why not just add a new property to the tag that you can use as the color?