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: 
Microsoft has built in functions for this:

```
someString = someString.PadLeft(8, '0');

```

And here's an article on [MSDN](http://msdn.microsoft.com/en-us/library/dd260048.aspx)

To use a regular expression, do something like this:

```
string someText = "asd 123 rete"; 
someText = Regex.Replace(someText, @"\d+", n => n.Value.PadLeft(8, '0'));

```
```
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 :)