I'm on Linux ( CentOS ) and I'm trying to capture from something that looks like
This, formatting | is, 123gh234ee2, {absolutely}, [ positively | obnoxious | in ], {every}, [ {single} | {way} ],, Thanks | For your | Help!
What I want is to replace all pipes |, but only those within [ ]. So...
This, formatting | is, 123gh234ee2, {absolutely}, [ positively ; obnoxious ; in ], {every}, [ {single} ; {way} ],, Thanks | For your | Help!
I've tried several expressions, but the one I think should work doesn't. Can anyone explain why?
sed -i 's/(?<=\[)(\|)(?=\])/;/g' 'myFile.txt'
My idea was do a look ahead for the [ with
(?<=\[)
Do a look behind with
(?=\])
And capture the pipes with
(\|)
However nothing in my file changes and I really can't seem to place my finger on what's wrong.
Thanks!
To clarify, I've also tried the perl method of
cat '/myFile.txt' | perl -ne 's/(?<=\[)(\|)(?=\])/xxxxx/g; print;'
And still do not get a changed result.