in reply to Re: How to clean an array of strings after a split
in thread How to clean an array of strings after a split

Thanks, but please explain what this does: (?:^|\|) and this: (?=$|\|)

Replies are listed 'Best First'.
Re^3: How to clean an array of strings after a split
by hdb (Monsignor) on Aug 29, 2013 at 14:37 UTC
    (?: non-capturing parentheses ^ start of string | or \| pipe character )
    (?= look-ahead, not part of match $ end of string | or \| pipe character )

    So I am looking for something between the start of string or a pipe and a pipe or the end of the string, ignoring whitespace, matching non-greedily. In order to make it work, I need to use each pipe twice, once for the string before the pipe, and then for the string following it. Thus the look-ahead assertion. HTH.