I'm having a bit of a problem with this... I'm trying to use Bash scripting (Sed, in particular) to process the following text. Other methods are welcome, of course! But I'm hoping it could be a Bash solution...
Tricky input:
("a"|"b"|"c")."A"|"B"|"C".("e"|"f")."E"|"F"
Desired output:
("a"|"b"|"c")."ABC".("e"|"f")."EF"
Mainly, I think what I want to do is replace the strings "|"
with nothing, but limit the scope of change outside of any existing text in parentheses.
The problems gets more crazy with different forms of text inputs I have with the dataset that I have. As in, the combination of blocks (delimited by .
) with parentheses and non-parenthesese is varied.
Thanks in advance.
Something I've tried with SED:
gsed -E "s/(."[[:graph:]]+)"|"/1/g" input.txt
output i get is:
("a"|"b"|"c")."A"|"B"|"C".("e"|"f")."EF"
Looks like I'm only getting the partially desired output...only targeting a limited scope...
question from:https://stackoverflow.com/questions/65836789/using-sed-to-replace-specific-patterns-found-within-parentheses