kcep Posted November 6, 2007 Posted November 6, 2007 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)
sbg2 Posted November 6, 2007 Posted November 6, 2007 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 )
Søren Dyhr Posted November 6, 2007 Posted November 6, 2007 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
kcep Posted November 6, 2007 Author Posted November 6, 2007 WORKS PERFECTLY :-) WOW THANK YOU SO MUCH :-)
comment Posted November 6, 2007 Posted November 6, 2007 (edited) How about something simple: Let ( [ len = Length ( text ) ] ; Right ( text ; len - Position ( text ; ", " ; len ; -1 ) - 1 ) ) Edited November 6, 2007 by Guest
Søren Dyhr Posted November 6, 2007 Posted November 6, 2007 Indeed much better, I havn't noticed this: A negative occurrence value causes the scan to go in the opposite direction Thanks Michael!! --sd
comment Posted November 6, 2007 Posted November 6, 2007 Actually, I've made a stupid mistake, but the principle is right and I have fixed it now.
kcep Posted November 6, 2007 Author Posted November 6, 2007 Thank you everyone ... I love all the different answers.
Recommended Posts
This topic is 6384 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now