Re: find strings and add text

"Christopher Stone [email protected] [sed-users]" <[email protected]> Sat, 20 May 2017 13:01:47 -0500
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
On 05/20/2017, at 12:08, Rachid Mokrani <[email protected]> wrote:
> I can not find a simple sed command that will allow me to do this.
> 
> echo "221b Baker St, Marylebone,  32861 London"
> 
> TO:
> 
> 221b Baker St, Marylebone,  ; 32861 ; London
______________________________________________________________________

Hey Rachid,

If your version of sed supports word-boundaries then this is simple:

---------------------------------------------------

#!/usr/bin/env bash

strVar='221b Baker St, Marylebone,  32861 London'

gsed -r 's!\b([0-9]{5})\b! ; \1 ; !' <<< "$strVar"

---------------------------------------------------

If it doesn't then please tell us what OS and what version of sed you're using.

--
Best Regards,
Chris