How to count spaces in text?

In the following example, there are 4 spaces before inet.

wolf@linux:~$ ip address show eth0 | grep 'inet '
    inet brd scope global dynamic eth0

How do I count the number of spaces like this example.

This sample is easy as it only has 4 spaces.

What if it has more than that? Hundreds, thousands?

Is there an easy way to do this?

Go to Source
Author: Wolf