Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Highlighting specific phrases in a text field based on regular expression?

Featured Replies

I'm building a database of news articles for a research project. I have a text field called FullText into which I'll paste the text of each article.

What I'm trying to do is to programmatically find all quotes in the article and highlight them with a particular color. That way I can quickly scan the article to see who's being quoted.

The simplest way to define a 'quote' is any text in between quotation marks (straight quotes or curly quotes, single or double.) A more complicated kind of quote could be looking for the word "said" and highlighting the entire sentence, in the case where the author is summarizing information she got from an outside source.

Since I don't think FileMaker lets you use regular expressions in a script, I'm at a loss how to do this. Any advice is greatly appreciated!

Thanks,

Daniel

Well it can be accomplished with a combination of event trigged scripting as well as a custom function:

http://www.briandunning.com/cf/13

...which I here have simplified a tiny bit. The reason why I think it should be solved somewhat in that direction is that, the task as such violates very initial normalization, since one fact per field hardly ever would be the case ... indexing pages of text is unfortunately going to make the indexing quite comprehensive with whopping filesizes as result.

By instead letting the calculation engine look for the first occurence in each of the text of a keyword, could a relational selfjoin key be established - from where a GTRR(FS) would land the user in a smaller found set, or none ... if the match doesn't work.

By letting the custom function take care of the formatting will browsing thru a found set via conditional buttons - evaluate each time a new record is launched, is it done in the event only.

In the attached template, fill in the search field in the second tab/pane and then choose the highlight tab/pane and initially try with words like {duck;bird;night}

If this shouldn't be sufficent, could you probably adapt what Shawn here have a template doing - in the gist of regular expressions:

http://www.spf-15.com/fmExamples/

--sd

highGtrr.zip

  • Author

Søren, thanks, this looks like a very promising direction.

Since I'm looking for any text between quotation marks, for example, how would I format that request using this custom function?

Shawns or mine? It looks like it mine you're referring to - since his is a Medusas head of interacting CF's...

But I do not quite get what you mean...?

--sd

  • Author

Hey Søren, thanks for the clarification, I missed some of the links you attached the first time. I was looking at the highlighting custom function you linked to on briandunning.com, but now that I'm looking at Shawn's regular expression custom functions that looks very helpful as well.

Thanks for the example you attached with the word "bird" highlighted. I pasted in a news article and searched for the " character, which did indeed highlight all the quotation marks in the text. Can you offer advice on how to highlight the text between the quotation marks as well as the marks themselves? That's the part I'm stuck on.

I am certainly not an experienced programmer but from the little I do know the way to express what I'm looking for in the text is the regular expression ".*" but I'm not sure how to achieve that in FileMaker. It looks like I could use Shawn's custom functions to allow the use of regular expressions in combination with Brian's/your highlighting function?

Thanks for the help!

Daniel

You might want to check out this plugin, it could make your life a little easier.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.