This solution makes the assumption that if spaces occur, they will always occur at four-digit intervals. The OP didn't say that was the case. While it may be the case, we're not sure.
Your use of tr/// is ineffective, at any rate. It's doing nothing. If evaluated in scalar context it would return the number of spaces found, but if you intended to delete spaces, you need to add the /d modifier. However, that would be contrary to what the OP was asking. In his example output, whitespace is preserved.
Dave
In reply to Re^2: How to write a regular expression to extract a number from an embedded string?
by davido
in thread How to write a regular expression to extract a number from an embedded string?
by jwking
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |