enquirerfm Posted October 14, 2010 Posted October 14, 2010 (edited) Hi, Is there a way to obtain any number of words e.g. 3, 4, 5 or 6 say which are to the left of an opening bracket ( or alternatively to the left of a 1,2,3 or 4-digit number/ Thx. For example: Green large t-shirt (some text here) to obtain: Green large t-shirt or Green large t-shirt 234 to obtain: Green large t-shirt Since there might be any number of words before the bracket is there a way to look for the start of the bracket and just keep the words to the left of it? Edited October 14, 2010 by Guest
comment Posted October 14, 2010 Posted October 14, 2010 Try = Trim ( Left ( text ; Position ( text ; "(" ; 1 ; 1 ) - 1 ) ) or alternatively to the left of a four-digit number Not quite the same thing.
Lee Smith Posted October 14, 2010 Posted October 14, 2010 Try: Left ( YourTextField ; Position ( YourTextField ; " (" ; 1 ; 1 ) - 1 ) Note: I put a space before the ( because your example had one. HTH Lee
TheTominator Posted October 14, 2010 Posted October 14, 2010 (edited) or alternatively to the left of a four-digit number If your field is named "myDataField" then... Let( [ fourDigitNum = Left(Filter(myDataField;“0123456789”); 4) ]; Case( Length(fourDigitNum) = 4; Trim ( Left ( myDataField ; Position ( myDataField ; fourDigitNum ; 1 ; 1 ) - 1 ) ); "" ) ) Edit: To generalize this to 1, 2, 3, or 4-digit numbers... Let( [ fourDigitNum = Left(Filter(myDataField;“0123456789”); 4) ]; Case( (Length(fourDigitNum) > 0) and (Length(fourDigitNum) ≤ 4); Trim ( Left ( myDataField ; Position ( myDataField ; fourDigitNum ; 1 ; 1 ) - 1 ) ); "" ) ) Edited October 14, 2010 by Guest
comment Posted October 14, 2010 Posted October 14, 2010 or alternatively to the left of a 1,2,3 or 4-digit number But not a 5-digit number?
enquirerfm Posted October 14, 2010 Author Posted October 14, 2010 Yes, I can't think of the problems fast enough. Thank you it's problem solving in real time!
enquirerfm Posted October 14, 2010 Author Posted October 14, 2010 Right. I have a field which might look like this: Green trousers (large) Ignore the fact that the word in brackets is 3rd word from left but it is always last. I want to be able to cut the word 'large' out of this and post it into another field. Thx
Raybaudi Posted October 14, 2010 Posted October 14, 2010 If it is always only one word: RightWords ( text ; 1 )
comment Posted October 14, 2010 Posted October 14, 2010 See: http://fmforums.com/forum/showpost.php?post/289685/
enquirerfm Posted October 14, 2010 Author Posted October 14, 2010 This looks complicated. Suppose I had this: green trousers (large size 2) or black outdoor jacket (large size 2) How would I trim away everything to the left of the bracket "(". Then I could just substitute the () with blanks and post what remains??
enquirerfm Posted October 14, 2010 Author Posted October 14, 2010 These solutions worked well but the first was sufficient: Trim ( Left ( text ; Position ( text ; "(" ; 1 ; 1 ) - 1 ) ). Is there a way I could use this so that I would be left with what I originally discarded? For example: Green large t-shirt (some text here) to obtain: (some text here) Thx.
Lee Smith Posted October 14, 2010 Posted October 14, 2010 (edited) Using comment's calculation, but modified to fit your need. Let ( [ start = Position ( YourTextField ; "(" ; 1 ; 1 ) + Length ( "(" ) ; end = Position ( YourTextField ; ")" ; start ; 1 ) ] ; Middle ( YourTextField ; start ; end - start ) ) Edited October 14, 2010 by Guest
Lee Smith Posted October 14, 2010 Posted October 14, 2010 To include the brackets, then modify it like this. Let ( [ start = Position ( YourTextField ; "(" ; 1 ; 1 ) + Length ( "(" ) ; end = Position ( YourTextField ; ")" ; start ; 1 ) ] ; "(" & Middle ( YourTextField ; start ; end - start ) & ")" )
enquirerfm Posted October 24, 2010 Author Posted October 24, 2010 Tried but not succeeded at also trimming everything away to the right of the '(' - another use, and including the '(' itself. So; t-shirt red $40 (small) would yield: t-shirt red $40 The content of the brackets constantly changing the only universal constant is the existence of the bracket itself. Thx.
Lee Smith Posted October 24, 2010 Posted October 24, 2010 No, not thanks. You either have changed what you are describing as you need, or the calculations should work. Left ( YourTextField ; Position ( YourTextField ; " (" ; 1 ; 1 ) - 1 ) will give you [color:blue]t-shirt red $40 and Let ( [ start = Position ( YourTextField ; "(" ; 1 ; 1 ) + Length ( "(" ) ; end = Position ( YourTextField ; ")" ; start ; 1 ) ] ; "(" & Middle ( YourTextField ; start ; end - start ) & ")" ) will give you [color:blue](small) Lee
Recommended Posts
This topic is 5144 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