[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: delimiters with more than one character? ...



Albretch Mueller (12020-07-14):
>  I have a string delimited by two characters: "\|"
> 
>  _S=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc "
> 
>  which then I need to turn into a array looking like:
> 
>   _S_AR=(
> " 34 + 45 "
> " abc "
> " 1 2 3 "
> " c"
> "123abc "
> )
> 
>   I can't make awk or tr work in the way I need and all examples I
> have found use only one character.
> 
>   Is it possible to do such things in bash?

In bash I do not know, but zsh can do it easily:

$ a="abcxydefxyghi"; echo ${(s:xy:)a}
abc def ghi

I leave as an exercise the task of properly escaping backslash and pipe
if necessary.

Regards,

-- 
  Nicolas George

Attachment: signature.asc
Description: PGP signature


Reply to: