Spotfire limit data-By text with Regular Expressions

Spotfire limit data-By text with Regular Expressions

book

Article ID: KB0078684

calendar_today

Updated On:

Products Versions
Spotfire Analyst All supported versions

Description

Regular Expression comparison function ~= can be easily used to limit data on String values.

For example: The expression "If( Arg1 ~= Arg2 , true, false)"  returns true if the Arg2 regular expression string matches the Arg1 string

Issue/Introduction

Limit data is usually based on integer columns but it can be easily limited on String columns with a Regular expression function.

Resolution

Consider the sample data set :
 
IDFruit
1Apple
2Fruit
3Banana
4fruit
5Kale
6fru
7Kiwi
8fr
9Mango
10fruits
11Orange
12fru$
13thisfruits++
Here are some examples that can be used in custom expression to limit the data -

1)If(Lower([Fruit]) ~= "fr*",false,true) 
All fruits not starting with "fr"

2)If(Lower([Fruit]) ~= "fr*",true,false)
All fruits starting with "fr"

3)If(Lower([Fruit]) ~= "a$",true,false)
All fruits ending in "a"

4)If(Lower([Fruit]) ~= "^[f-m]",false,true)
All fruits not starting with "f" or "m"

5)If(Lower([Fruit]) ~= "k[a-z]*[e-i]$",true,false)
All fruits starting with "k" and ending with "e" or "i"

6)If(Lower([Fruit]) ~= "l+",true,false)
one or more occurences of "l" in fruit names

7)If(Lower([Fruit]) ~= "[no]",true,false)
one of the characters in the bracket

8)If(Lower([Fruit]) ~= "[1-9]+",true,false)
All fruits containing one or more occurences of digits


Note: Meaning of quantifiers in regular expressions
$ - Ending with this character
? - one or none 
+ - one or more
* - zero or more

An example Spotfire analysis file is attached for reference.

Additional Information

This wiki article explains a similar use-case using python scripting.

Attachments

Spotfire limit data-By text with Regular Expressions get_app