tagparameterarray(
TEXT
,
TAG
,
SEPARATOR
)

The tagparameterarray( function extracts the value of multiple tag parameters embedded in some text, where each tag parameter takes the form name=value.


Parameters

This function has three parameters:

text – is the item of text that contains the data you want to extract.

tag – is the name of the tag parameter you want to extract, including the trailing = sign (you may use other terminators, for example colons (font:Helvetica) or period (font.Helvetica). For example, if you want to extract the font name from the text font=Helvetica size=12 the tag would be font=.

separator – is the separator character for the output array.


Description

The tagparameterarray( function extracts the value of multiple tag parameters embedded in some text, where each tag parameter takes the form name=value. This function returns an array of all instances of the specified parameter within the text. If the parameter is surrounded by quotes, the quotes are removed. (Quotes are necessary if the parameter value contains spaces, for example font="Times Roman". Allowed quote characters include double quotes ("), single quotes ('), single and double smart quotes (“” ‘’), curly brackets ({}) and multiple pipe characters (|).

Here is an example that assumes that you have a field name Orders that contains food orders like this:

<pizza topping=pepperoni topping=mushroom>
<pizza topping=olive>
<rigatoni sauce=red>
<pizza topping=clam topping=garlic>
<linguine sauce=white>

The procedure shown below can process this data

local pizzaOrders,pizzaToppings
pizzaOrders=tagarray(Orders,"<pizza",">",cr())
arrayfilter pizzaOrders,pizzaToppings,cr(),
    tagparameterarray( import(), "topping=",",")

The final result is a list of toppings

pepperoni,mushroom
olive
clam,garlic

Although this example is not all that practical, this is a very powerful function for parsing languages like HTML, XML, or your own specification languages.


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but now allows the separator parameter to be omitted (carriage return will be assumed).