Jump to content
Sign in to follow this  
kcep

Right Words - Text calculation

Recommended Posts

I need to pull out the right words from a text field. The information in the field is separated by a comma ... sometimes one comma ... other times more than one. I only need the text that follows the last comma.

Example 1: Mary Had A Little Lamb, cassette - sheet music (the calculated result should be: cassette - sheet music)

Example 2: World Is Round, The, VHS (the calculated result should be: VHS)

Share this post


Link to post
Share on other sites

One way would be...

Let ( [

// Change to a return seperated list

Step1 = Substitute(MyTextField; ","; ¶) ;

// Get the last value in list

Step2 = RightValues(Step1;1);

// Remove trailing Carriage Return

Step3 = Substitute(Step2; ¶; "");

// Trim it up

Step4 = Trim(Step3)

]

; Step4 )

Share this post


Link to post
Share on other sites

Why do you think 1NF says one fact per field? Anyways here's my stab at it:

Let(rough= yourString ;Replace ( rough ; 1 ; 1+Position ( rough ; ","; 1 ; Length(Filter ( rough ; "," )) ) ; "" ))

What it does, is taking the last comma, and get the text following it!

--sd

Share this post


Link to post
Share on other sites

WORKS PERFECTLY :-)

WOW !!!

THANK YOU SO MUCH :-)

Share this post


Link to post
Share on other sites

How about something simple:

Let ( [

len = Length ( text )

] ;

Right ( text ; len - Position ( text ; ", " ; len ; -1 ) - 1 )

)

Edited by Guest

Share this post


Link to post
Share on other sites

Indeed much better, I havn't noticed this:

A negative occurrence value causes the scan to go in the opposite direction

Thanks Michael!!

--sd

Share this post


Link to post
Share on other sites

Actually, I've made a stupid mistake, but the principle is right :smile: and I have fixed it now.

Share this post


Link to post
Share on other sites

Thank you everyone ... I love all the different answers.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

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