Jump 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.

search string by value list

Featured Replies

  • Newbies

What I need is a function that will test whether any member of a value list is in a text string, if true, it should return the value.

"the brown cow needs milk"

compare to value list "milk toast|jaguar|brown cow|red cow"

should return "brown cow"

This differs from most requirements in that the value list may contain multiple words, while the text string is a sentence.

One option is to explode the text string into a list of each word, followed by pairs of words, followed by phrases of 3., similar to the ExplodeKey custom function for individual words.

However, I am having trouble wrapping my head around nested recursive functions, and I don't have time to fully grok it right now.

Can someone point me to a custom function that does this?

For example, this

ExplodeKey (string)

Case ( string = "" ; "" ;

ExplodeKey ( LeftWords ( string ; Wordcount (string) - 1 ) ) & string & "¶"

)

)

will get me a list with the first word followed by each additional word

But next I need to lop off the first word, then do it again, then lop of the next word...

How do I do this?

I believe you should recurse on the values of the value list, rather than on the words of the string. However, this may not be enough to eliminate a positive answer when the value list contains "red cow" and text contains "hired coworkers".

Wrote up a custom function for you. Enjoy! :(


// ValuesFoundInText ( text ; listOfValues )

// 

// Searches a text string for each value in a list and returns a list of the values that exist in the text

//

// Parameters:

// text - the text to search

// listOfValues - a return delimited list of search strings

Let(

    [

        numberOfValues = ValueCount( listOfValues );

        searchString = GetValue( listOfValues; 1 );

        restOfTheValues =

        RightValues( listOfValues; numberOfValues - 1 );

        doneWithValues = not ValueCount( restOfTheValues );

        firstPart =

        Case( PatternCount( text; searchString ); searchString );

        thirdPart =

        Case(

            not doneWithValues;

            ValuesFoundInText( text; restOfTheValues )

        );

        secondpart =

        Case( ValueCount( firstPart ) and ValueCount( thirdPart ); "¶" )

    ];

    firstPart & secondPart & thirdPart

)

Create an account or sign in to comment

Important Information

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

Account

Navigation

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.