Question: I want to pad left every number with zeroes (it has to be 8 digits) in my string.

e.g.

```
asd 123 rete > asd 00000123 rete
4444 my text > 00004444 my text

```

Is it possible to do this using regular expressions? Especially `Regex.Replace()`?

Notice that the number of zeroes is different for different numbers. I mean the padded number has to be 8 digits long.

Answer: 
If you don't have any attachment to Regex just use format strings:

[C# convert int to string with padding zeros?](https://stackoverflow.com/questions/4325267/c-sharp-convert-int-to-string-with-padding-zeros)

<http://www.xtremedotnettalk.com/showthread.php?t=101461>
```
static void Main(string[] args)
    {
       string myCC = "4556364607935616";
       string myMasked = Maskify(myCC);
       Console.WriteLine(myMasked);
    }        

public static string Maskify(string cc)
    {
       int len = cc.Length;
       if (len <= 4)
          return cc;

       return cc.Substring(len - 4).PadLeft(len, '#');
    }

```

Output:
=======

######5616

Just replace the '#' with 0 or '0'.
Hope that helped :)