in reply to replace nth occurrence of |

Using the embedded counter in the regex is too clever for its own good. And why use a delimiter that appears in the data? That is just making your job harder than it needs to be.

1 Peter 4:10

Replies are listed 'Best First'.
Re^2: replace nth occurrence of |
by perl197 (Novice) on Sep 24, 2014 at 17:36 UTC

    I'm parsing data in a log file of which the last data appended to the line consists of a unix command line entry. As commands submitted by the user may or may not include a |, (or any command line character) I wanted to replace my chosen delimiter within the command text with a benign value so as to not error out the bulk load to a table. By and large there will rarely be one | never mind 3, but wanted to cover my bets just in case.