Shay Well-Known Member Licensed User Longtime User Oct 1, 2011 #1 I wish to remove only the left "0" in this string (can't find how to do it) a="0540123456" thanks
H hdtvirl Active Member Licensed User Longtime User Oct 1, 2011 #2 Look at the following Shay, have a look at this tutorial from Erel, regex http://www.b4x.com/forum/basic4andr...3-regular-expressions-tutorial.html#post40844 You can use this fucntion to get the part of the stringyou want. substring2 (Core) you will need to look at a tutorial on this also for full explaination of its use. Regards BOB Upvote 0
Look at the following Shay, have a look at this tutorial from Erel, regex http://www.b4x.com/forum/basic4andr...3-regular-expressions-tutorial.html#post40844 You can use this fucntion to get the part of the stringyou want. substring2 (Core) you will need to look at a tutorial on this also for full explaination of its use. Regards BOB
boten Active Member Licensed User Longtime User Oct 1, 2011 #3 if it is just the leftmost char then: B4X: a=a.substring(1) if you want the first occurance of "0" (wherever it is) then: B4X: for i=0 to a.length-1 if a.substring2(i,i+1)="0" then a=a.substring2(0,i) & a.substring(i+1) exit end if next Upvote 0
if it is just the leftmost char then: B4X: a=a.substring(1) if you want the first occurance of "0" (wherever it is) then: B4X: for i=0 to a.length-1 if a.substring2(i,i+1)="0" then a=a.substring2(0,i) & a.substring(i+1) exit end if next
nfordbscndrd Well-Known Member Licensed User Longtime User Oct 1, 2011 #4 Shay said: I wish to remove only the left "0" in this string (can't find how to do it) a="0540123456" Click to expand... If you are familiar with VB syntax, you may want to look at the VB6-to-B4A guide in this post. Also, this page in the Documentation Wiki (see the yellow link in the menu bar above) covers all String functions. Upvote 0
Shay said: I wish to remove only the left "0" in this string (can't find how to do it) a="0540123456" Click to expand... If you are familiar with VB syntax, you may want to look at the VB6-to-B4A guide in this post. Also, this page in the Documentation Wiki (see the yellow link in the menu bar above) covers all String functions.
P pjd Member Licensed User Longtime User Oct 1, 2011 #5 Here you go ... a="540123456" I'll get my coat. Upvote 0
Kevin Well-Known Member Licensed User Longtime User Oct 1, 2011 #6 pjd said: Here you go ... a="540123456" I'll get my coat. Click to expand... Well, I was going to say "with a pair of scissors"...... (Sorry about that. His question was answered so I'm just having a bit of fun. I'm tired.) Upvote 0
pjd said: Here you go ... a="540123456" I'll get my coat. Click to expand... Well, I was going to say "with a pair of scissors"...... (Sorry about that. His question was answered so I'm just having a bit of fun. I'm tired.)
margret Well-Known Member Licensed User Longtime User Oct 2, 2011 #7 String Functions Hello, You can also try my function file that gives you a lot of functions to cut and change strings. It has sample code and functions like: Right() Left() Mid() Len() To do what you are looking for would be: YouVariable = Right("0540123456" , Len("0540123456") -1) And a lot more. You can see and download here: http://www.b4x.com/forum/basic4android-getting-started-tutorials/10365-string-functions.html Thanks, Margret Last edited: Oct 3, 2011 Upvote 0
String Functions Hello, You can also try my function file that gives you a lot of functions to cut and change strings. It has sample code and functions like: Right() Left() Mid() Len() To do what you are looking for would be: YouVariable = Right("0540123456" , Len("0540123456") -1) And a lot more. You can see and download here: http://www.b4x.com/forum/basic4android-getting-started-tutorials/10365-string-functions.html Thanks, Margret
Brad Active Member Licensed User Longtime User Oct 3, 2011 #8 boten said: if you want the first occurance of "0" (wherever it is) then: B4X: for i=0 to a.length-1 if a.substring2(i,i+1)="0" then a=a.substring2(0,i) & a.substring(i+1) exit end if next Click to expand... Here's a simpler way to remove all occurrences of a character. a = "08934060" a = a.Replace("0","") returns 89346 Upvote 0
boten said: if you want the first occurance of "0" (wherever it is) then: B4X: for i=0 to a.length-1 if a.substring2(i,i+1)="0" then a=a.substring2(0,i) & a.substring(i+1) exit end if next Click to expand... Here's a simpler way to remove all occurrences of a character. a = "08934060" a = a.Replace("0","") returns 89346