Dear Gregory
"123456789" I want to extract single digit or double digit from any position.
Regards.
How to extract number
-
- Posts: 572
- Joined: July 9th, 2012, 11:32 am
- Location: Islamabad, Pakistan
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: How to extract number
If this is a numeric value, you may find it most easy to convert it to a string first. For example, to get the first two digits, you could write:
maketext("%d",xxx)[1:2]
However, that will return it as a string. If you want it as a number again, you can write this:tonumber(maketext("%d",xxx)[1:2])
If you want digits from the right of the string, you could use the modulo operator. The last two digits are:xxx % 100
You can use divide and modulo to get middle sections of the string. For example, to get the tens and hundred digits, you would write:( xxx / 10 ) % 100
-
- Posts: 572
- Joined: July 9th, 2012, 11:32 am
- Location: Islamabad, Pakistan
Re: How to extract number
Dear Gregory
Thanks.
arshad
Thanks.
arshad