fork download
  1. #!/bin/bash
  2. s="B'10' AB'1010' B'1010101010'"
  3. sed -E ":a; s/(\bB'(12)*)10((10)*')/\112\3/g; t a" <<< "$s"
  4.  
Success #stdin #stdout 0s 19632KB
stdin
Standard input is empty
stdout
B'12' AB'1010' B'1212121212'