| Author |
Message |
nebchill26
Newbie
Joined: 06 Nov 2008
Location: Philippines
Online Status: Offline
Posts: 20
|

Topic: how to separate string? Posted: 26 Jun 2011 at 3:21pm |
|
hi does anyone know how to separate the 0 in this string? "000000000006628", i just need to separate the "0" from 6628 or any other number and sometimes the string can be like this "00002986".The separated string must look like this "00000000000" and "6628". Your help will be much appreciated. Thanks
Edited by nebchill26 - 26 Jun 2011 at 3:38pm
|
IP Logged |
|
|
|
FrnhtGLI
Senior Member
Joined: 22 May 2009
Online Status: Offline
Posts: 347
|

Posted: 27 Jun 2011 at 3:06am |
|
Okay, so like with many of my posts, there may be a simpler solution, but mine will work as well. Create two formulas.
Formula 1: To get the Non-Zero number: local stringvar nReverse:=strreverse({@OriginalString}); nReverse:=left(nReverse, instr(nReverse, '0')-1); strreverse(nReverse);
Formula 2: To get the Zeroes: evaluateafter({@NonZeroString}); local numbervar nStringLength:=len({@OriginalString}); local numbervar nLengthNonZero:=len({@NonZeroString});
left({@OriginalString}, instr({@OriginalString}, '0')+(nStringLength - nLengthNonZero-1));
Edited by FrnhtGLI - 27 Jun 2011 at 3:09am
|
|
|< /\ '][' ( )
|
IP Logged |
|
nebchill26
Newbie
Joined: 06 Nov 2008
Location: Philippines
Online Status: Offline
Posts: 20
|

Posted: 27 Jun 2011 at 3:00pm |
|
hey its great! thanks for the reply man! just a follow up question what about if the string is "0000062800" can i still split this as "00000" and "62800" using the same formula?
|
IP Logged |
|
CircleD
Senior Member
Joined: 11 Mar 2011
Location: United States
Online Status: Offline
Posts: 251
|

Posted: 27 Jun 2011 at 4:37pm |
|
Looking at his formula it appears you can.He's pulling off the "0's" from the left of the number string up to the positive numbers and leaving everything else.I freely admit I'm not the best when it comes to formulas though so you may have to give it a real world test to make sure.
|
IP Logged |
|
nebchill26
Newbie
Joined: 06 Nov 2008
Location: Philippines
Online Status: Offline
Posts: 20
|

Posted: 27 Jun 2011 at 5:09pm |
|
i tried it using it but when i put a zero(0) on the right most part the formula wont split the string
|
IP Logged |
|
FrnhtGLI
Senior Member
Joined: 22 May 2009
Online Status: Offline
Posts: 347
|

Posted: 28 Jun 2011 at 1:58am |
|
Sorry, but as you have found out, my formula will not work if zeros are at the end of the number.
I believe I have found a more simple solution that will work even if zeros are at the end.
Formula 1: Non-Zero number (with or without zeros at the end):
replace(totext(cdbl({@OriginalString}),0), "," , "")
You should be able to keep the second formula as it is.
Hope this one works for you.
Edited by FrnhtGLI - 28 Jun 2011 at 1:58am
|
|
|< /\ '][' ( )
|
IP Logged |
|
nebchill26
Newbie
Joined: 06 Nov 2008
Location: Philippines
Online Status: Offline
Posts: 20
|

Posted: 28 Jun 2011 at 10:25pm |
It works!Thank you very much for your help!
|
IP Logged |
|
|
|