November 17, 200619 yr Can any body help me with a calculation to extract the middle character/s of a long number or a text string, eg, the 5th character in the number 12345678 or the 4th letter in stephen In both of the examples I will not know the contents of the number or text string, they will be different every time. Steve
November 17, 200619 yr Hi assuming that the middle character of an even lenght string is the last char of the middle count of chars ( and in your first example it must be the 4th) Let( len = Lenght(YourString); Case( mod ( len ; 2 ); Div ( len ; 2 )+ 1; Div ( len ; 2 ) ) this calc can be simplified to: Let( len = Length ( YourString ); Div ( len ; 2 ) + Mod ( len ; 2 ) )
November 17, 200619 yr Author Thanks for your post but it's not giving me the result I need. After testing your caculation it returns a 6 for the serial number UV432007QHU, but in this instance I would need the 0 in the middle? I think your calculation just counts the middle character, but I need to know exactly what it is, eg, 0 in the serial number above.
November 17, 200619 yr How about: Let ( [ len = Length ( string ) ; mid = Ceiling ( len / 2 ) ] ; Middle ( string ; mid ; 1 ) )
November 17, 200619 yr oops... yes, you can use the comment calc or this one Let([ len = Length ( YourString ); mid = Div ( len ; 2 ) + Mod ( len ; 2 ) ]; middle( YourString ; mid ; 1 ) )
Create an account or sign in to comment