October 14, 201015 yr 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, 201015 yr by Guest
October 14, 201015 yr Try = Trim ( Left ( text ; Position ( text ; "(" ; 1 ; 1 ) - 1 ) ) or alternatively to the left of a four-digit number Not quite the same thing.
October 14, 201015 yr Try: Left ( YourTextField ; Position ( YourTextField ; " (" ; 1 ; 1 ) - 1 ) Note: I put a space before the ( because your example had one. HTH Lee
October 14, 201015 yr 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, 201015 yr by Guest
October 14, 201015 yr or alternatively to the left of a 1,2,3 or 4-digit number But not a 5-digit number?
October 14, 201015 yr Author Yes, I can't think of the problems fast enough. Thank you it's problem solving in real time!
October 14, 201015 yr Author 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
October 14, 201015 yr Author 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??
October 14, 201015 yr Author 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.
October 14, 201015 yr 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, 201015 yr by Guest
October 14, 201015 yr 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 ) & ")" )
October 24, 201015 yr Author 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.
October 24, 201015 yr 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
Create an account or sign in to comment