On Sep 4, 2009, at 9: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?

   "000000100".sub(/\A0+/, "")

\A means the beginning of the String and 0+ means one or more zeros.

Also note the use of sub() which only matches once over gsub() which  
is used to repeat for all matches.  There can only be one run of zeros  
at the front of the String, so sub() is all we need.

Hope that helps.

James Edward Gray II