in reply to Re: Counting to add space to a string
in thread Counting to add space to a string

In your first example, your code is inserting the X after the fourth char, but the OP says "after the initial letters".

  • Comment on Re^2: Counting to add space to a string

Replies are listed 'Best First'.
Re^3: Counting to add space to a string
by ww (Archbishop) on Sep 22, 2011 at 16:16 UTC

    Good point; ++. Another arguement for regex and length!>

    I failed to consider that OP's substr($account_1, 4, 0) hard codes the insert point; in fact, offhand, I don't see a direct way (other than a regex to find the last, initial letter (.oO ... there might be some non-initial letters? pos, and length) to fix that in my code.

    Update: That is, I didn't see it until your Re: Counting to add space to a string. Elegant and concise: ++ again!