Searching Text for Characters

October 4, 2019 Josiah Feuerbacher

This week, we’re going to take a detailed look at possibly the most powerful functions that we have in our scripting language. I’m going to assume you have some experience with scripting & expressions, so this one might be a little deep for beginners. 

The function is called match, and it searches a string of text for a pattern of characters. If the pattern exists, the function returns true. If not, it returns false. 


Let’s take a look at the general syntax of the function. It takes an input string, a pattern to search for, and an optional third parameter for matching criteria, like this: 

{&exp:match(InputString, Pattern, OptionalCriteria)} 

For instance, below I am searching the string “My String Here”, for the string “ring”: 

{&exp:match(‘My String Here’, ‘ring’} 

The expression above would return “True”, because the word “ring” can be found in the string “My String Here”. 

By default, the match function is case sensitive, so this function: 

{&exp:match(‘My String Here’, ‘RING’} 

Would return “False”, because the case no longer matches. That’s where the optional criteria come into play. You can specify that you want to ignore case sensitivity by using an “i” in the final parameter, like this: 

{&exp:match(‘My String Here’, ‘RING’, ‘i’} 

Now the expression will return “True”. 

Adding even more powerful, you can use regular expressions in the “Pattern” parameter (check out this quick guide if you aren’t familiar with regular expressions). For instance, you could use the following to search the string for the letter “r” followed by any two letters, followed by the letter “g”: 

{&exp:match(‘My String Here’, ‘r..g’, ‘i’} 

Why It’s Important 

So why is this useful? First, it can be very powerful in live data filters. Take the following scenario: 

You have a staff directory, including a name, title, and department. You want to display a list of all staff members where the title contains “Director”, OR the department equals “Executive”. 

In order to accomplish this with live data filters, you will need to use the match function in an expression. The expression would look like this: 

{&exp:match([title], ‘Director’) = ‘True’ OR [department] = ‘Executive’} is ‘True’ 

The match function is also very powerful for conditional formatting inside a live data layout. Let’s take the same directory scenario, but instead of filtering the list, you want to highlight each row with a director or member of the executive team. To do this, you could use something like this in a markup field: 

{&exp:match([title], ‘Director’) = ‘True’ OR [department] = ‘Executive’ ? ‘\\\\Server\\highlight_image.jpg’ : ”} 

More Information 

If you are interested in learning more about the match function, expressions, or scripting in general, keep an eye on this blog. We are currently putting together supplemental documentation on our Connect which will detail not only the match function, but all the expression functions. Stay tuned for more! 


Improving Visual Communications on Africa Mercy
Improving Visual Communications on Africa Mercy

FWI President and CEO David Levin talks about how he was able to improve the quality of the Visual Communic...

Next Up
Advancing Content in Preview
Advancing Content in Preview

Let's take a look at an easy tip for previewing content in FWI's Content Manager. Previewing content helps ...