philipcaplan Posted January 27, 2009 Posted January 27, 2009 Hello All I have a text field called "bigtextfield" which contains many lines of "tagged text" items of which the following are just three: <>Charlie Anylength <>[email protected] <>sometext I have a calculation field of the following format, which successfully does what I want, which is to "parse" the contents of the above field splitting the text of each <> into a separate field: Let ( [ start = Position ( bigtextfield ; "<>" ; 1 ; 1 ) + Length ( "<>" ) ; end = Position ( bigtextfield ; "¶" ; start ; 1 ) ] ; Middle ( bigtextfield ; start ; end - start ) ) However, it fails for the final line of "bigtextfield" because that one doesn't end with a return ("¶")!! Can someone give me a version which works even for a line which is followed by nothing! Many Thanks.
comment Posted January 27, 2009 Posted January 27, 2009 Try: Let ( [ start = Position ( bigtextfield ; "<>" ; 1 ; 1 ) + Length ( "<>" ) ; end = Position ( bigtextfield & ¶ ; ¶ ; start ; 1 ) ] ; Middle ( bigtextfield ; start ; end - start ) )
philipcaplan Posted January 27, 2009 Author Posted January 27, 2009 Thank you, comment. That seems to work nicely! The only time it doesn't work is if I have a typo in the name of the <> being extracted, in which case instead of being left blank, it seems to pick up the value of another <>!! Can you suggest a way to catch this? Thanks again.
comment Posted January 27, 2009 Posted January 27, 2009 Let ( [ pos = Position ( bigtextfield ; "<>" ; 1 ; 1 ) ; start = pos + Length ( "<>" ) ; end = Position ( bigtextfield & ¶ ; ¶ ; start ; 1 ) ] ; Case ( pos ; Middle ( bigtextfield ; start ; end - start ) ) )
philipcaplan Posted January 27, 2009 Author Posted January 27, 2009 Thanks, once again! It seemed to need one more ) at the end, but once that was put in it seems like it works perfectly. Your help is much appreciated. PHILIP
comment Posted January 27, 2009 Posted January 27, 2009 It seemed to need one more ) at the end I don't think so.
philipcaplan Posted January 28, 2009 Author Posted January 28, 2009 You're right... The final ")" was of course in your code, but I failed to include it when copying-and-pasting it. My apologies!
Recommended Posts
This topic is 5838 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