# the middle character of a long number or text string

This topic is 6159 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

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

##### Share on other sites

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 )

)

##### Share on other sites

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.

##### Share on other sites

Let ( [

len = Length ( string ) ;

mid = Ceiling ( len / 2 )

] ;

Middle ( string ; mid ; 1 )

)

##### Share on other sites

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 )

)

Thank you!

##### Share on other sites

This topic is 6159 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account