Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to remove zero using Regx

How to remove zero using Regx

Scheduled Pinned Locked Moved C#
tutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Exelioindia
    wrote on last edited by
    #1

    Hi all, Any one suggest me how to remove Zero in the first place. For eg : 0208 in this I want to remove the zero only in the first occurance, therfore the output should be like 208. how to achive this using reguler expression? Because i need a solution using reguler expression Also the length should be only 4. Thanks in advance

    Know is Drop, Unknown is Ocean

    E 1 Reply Last reply
    0
    • E Exelioindia

      Hi all, Any one suggest me how to remove Zero in the first place. For eg : 0208 in this I want to remove the zero only in the first occurance, therfore the output should be like 208. how to achive this using reguler expression? Because i need a solution using reguler expression Also the length should be only 4. Thanks in advance

      Know is Drop, Unknown is Ocean

      E Offline
      E Offline
      Exelioindia
      wrote on last edited by
      #2

      Hi all, Sorry for this post. I found the solution. Please tell me is this a correct solution Regex regex = new Regex(@"\d{4}", RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline); string result=""; if (regex.IsMatch("00585")) { regex = new Regex(@"^0*"); result= regex.Replace("000508050", @""); } OutPut: 508050

      Know is Drop, Unknown is Ocean

      N 1 Reply Last reply
      0
      • E Exelioindia

        Hi all, Sorry for this post. I found the solution. Please tell me is this a correct solution Regex regex = new Regex(@"\d{4}", RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline); string result=""; if (regex.IsMatch("00585")) { regex = new Regex(@"^0*"); result= regex.Replace("000508050", @""); } OutPut: 508050

        Know is Drop, Unknown is Ocean

        N Offline
        N Offline
        ncjlee
        wrote on last edited by
        #3

        hi just for suggestion.. you can actually check the regex syntax by using another software such as regexbuddy ;)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups