From: Rob Biedenharn Date: 2009-09-04T23:52:41+09:00 Subject: Re: Regular expressions - string substitution On Sep 4, 2009, at 10:24 AM, Ne Scripter wrote: > Hello all, > > A quick question if I have a string like so > > 000000100 > > and I want to remove the leading 0's to leave me with a string like so > > 100 > > What is the best way to do this? initially I was using > string.delete("0") but that obviously deletes every 0 and is not the > desired outcome. I then though string.gsub(/^0/, "") however this only > gets rid of the very first 0. Does anyone have any suggestions? > > Thanks a lot > -- string.sub(/^0*/,'') Or /^0+/ since both work if there are zeroes, but find nothing if the first character is not a 0. If your intention is to convert to a number, then one of the other responses will work, but since you presented a string and asked to be left with a string, I wanted to be sure you saw this simple tweak to what you'd already discovered. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com