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

Featured Replies

In a text string I need to identify the word number that a particular word is in the text field.

For example.

"The cat sat on the mat". I need to know that the word "sat" is word no.3 etc.

But I cant see which functions to use.

Can anyone help. Please.

John

Hi

this is a way:

PatternCount ( Substitute ( Replace ( text ; Position ( text ; "sat" ; 1 ; 1 ) ; Length ( text ) ; "xxx" ) ; " " ; "xxx" ) ; "xxx" )

EDIT: NOT a good way; I'll search a better one !

Edited by Guest

This is a bit better ...

Let([

adjString1 = TrimAll ( Substitute ( text ; ¶ ; " " ) ; 1 ; 1 );

adjString2 = Replace ( adjString1 ; Position ( adjString1; " sat " ; 1 ; 1 ) ; Length ( adjString1 ) ; " sat" );

adjString3 = Substitute ( adjString2 ; " " ; ¶ )

];

Case(

PatternCount ( adjString1 ; " sat " ); ValueCount ( adjString3 );

""

)

)

That doesn't seem very good either. What if the text is:

Sat the cat on the mat.

Or:

The cat sat, on the mat.

Or:

The cat sat? on the mat.

Or:

The cat "sat" on the mat.

I believe a recursive custom function is required here - here's a simple one that should do the job:

WordPositionSimple ( text ; searchWord ; startingWord )

Let ( [

thisWord = MiddleWords ( text ; startingWord ; 1 )

] ;

Case (

thisWord = searchWord ; startingWord ;

startingWord < WordCount ( text ) ; WordPositionSimple ( text ; searchWord ; startingWord + 1 ) ;

0

)

)

Note:

1. This always find the first occurrence of searchWord, at or after startingWord;

2. Just like the Position() function, the result is the position from the start of the entire text - regardless of the startingWord parameter.

Yes, comment, you are right...

that was *only* a bit better !

But this must work:

Let([

t1 = " " & TrimAll ( Substitute ( text ; ¶ ; " " ) ; 1 ; 1 ) & " ";

t2 = Filter ( t1 ; " abcdefghjkilmnopqrstuvwxyzABCDEFGHJKILMNOPQRSTUVWXYZ" );

t3 = Replace ( t2 ; Position ( t2 ; " sat " ; 1 ; 1 ) ; Length ( t2 ) ; " sat" )

];

Case(

PatternCount ( t2 ; " sat " ) ; WordCount ( t3 );

""

)

)

To me, that's still too specific. What if my text is not in English? I might be looking for "Søren" or "resumé" or "Надежда". Or, I could be looking for "cat" in "I had a cat-nap". And so on...

Ok, Ok... :

Create an account or sign in to comment

Important Information

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

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.