philipcaplan Posted December 16, 2013 Posted December 16, 2013 I have in an FMPro12 table a field containing data which is always text, each word separated by dashes (they are parts of URL's). Some entries will be a single word (so no dashes); others may be 2, 3 or more words (always separated by dashes). There will never be a 'space' in the field's data. Typical contents might be for example: entertainment european-holidays womens-jewelry-and-accessories Can some kind person give me the Calculation I can use to: (1) replace each 'dash' with a 'space' (2) then uppercase the first letter only of each word (ie, initial capitals) (3) and replace any occurrence of the word 'and' with '&' Many thanks in anticipation.
Wim Decorte Posted December 16, 2013 Posted December 16, 2013 let( [ _string = "womens-jewelry-and-accessories" ; _cleanString = Substitute ( _string ; [ "-" ; " " ] ; [ " and " ; " & " ] ) ; _properString = Proper ( _cleanString ) ]; _properString ) 1
Lee Smith Posted December 16, 2013 Posted December 16, 2013 Use the substitute function. If your field = This A How To & This & That. Proper (Substitute ( yourField ; [“-“; “ “ ]; [“and” ; “&”] ) ) I noticed that Wim is up early today and posted a Let, here is another way using the Substitute function. Lee 2
philipcaplan Posted December 16, 2013 Author Posted December 16, 2013 Thanks, Lee. That worked perfectly. And thanks for your reply Wim, although I must admit I found Lee's explanation easier to follow! Thanks to you both, and to FMForums for coming up trumps again! Philip
Lee Smith Posted December 16, 2013 Posted December 16, 2013 Hi Philip, The Let Function is easier to follow than the “if” or “Case” most of the time. I changed some of the words of Wim’s calculation to see if it would help you understand it better Let ( [ text = yourField ; //equals the _string by Wim. cleanString = Substitute ( text ; [ "-" ; " " ] ; [ " and " ; " & " ] ) ; // equals the same as my Substitute newText = Proper ( cleanString ) //Proper is a Function in FileMaker. ] ; newText )
Wim Decorte Posted December 16, 2013 Posted December 16, 2013 using the let makes it somewhat easier to troubleshoot, by asking of the various part if it does not seem to work. So instead of returning "newText" you could return "cleanString" and see what it did....
Recommended Posts
This topic is 4052 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