Remove leading zeros from a Number given as a string | C # program to implement the above approach ; Function to remove all leading zeros from a a given string ; Regex to remove leading zeros from a string ; Replaces the matched value with given string ; Driver Code
using System ; using System . Text . RegularExpressions ; class GFG { public static void removeLeadingZeros ( string str ) { string regex = " ^ 0 + ( ? ! $ ) " ; str = Regex . Replace ( str , regex , " " ) ; Console . WriteLine ( str ) ; } public static void Main ( string [ ] args ) { string str = "0001234" ; removeLeadingZeros ( str ) ; } }