I want to write a function to accept a single string that represent a credit card number as parameter and validates it with the format
9999 9999 9999
where 9 is any digit and each quadruplet is separated with a single space.
can't help you if you can't even figure that out for yourself...
That said, it's a completely incorrect way to "validate" a credit card number. Not only is the number of digits incorrect for some types of cards, there is a strict requirement for the number to be a valid credit card number which has nothing to do with there being some spaces in it.