Help with a sed expression

Hi, I have sed expressions that p→ßßes me off.
They work well according to regexp101 but not for sed, and it won’t explains why in any meaningful terms.
sed ‘s/(?<!\)(\r|\n)>//g’ |sed ‘s/(?<!\)(\r|\n)(?!(\r|\n|>))/ /g’|sed ‘s/(\s){2,}/ /g’|sed ‘s/(\r|\n){3,}/\n\n/g’|sed ‘s/\//g’

the first part says:

sed ‘s/(?<!\)(\r|\n)>//g’
sed: -e expression n°1, character 20: ) or ) unmatched.

What’s wrong with it ?? is

> dsfdsfsd
> sdfsdfsdfs\
> sfqsfsqdfd
> mklijmopiuj

> mklijmopiuj

> mklijmopiuj


Thanks for your help !

what do you want to achieve?? We don’t want this to become a XY problem

The single quotes (') seem to have transformed to other characters.

Didn’t look further at the regex syntax but your file needs to be in the pipe:

cat | sed 's/(?<!\)(\r|\n)>//g'

Then near the beginning you have
which probably should be just

But as @sradjoker said, please tell us what you try to do.

1 Like

sed does not support every regex operation. Look-ahead is one of them.
You can check what is supported in the documentation (also with extended regex).
If you need these fancy functions then look for perl or python.

Also, do you know you can make sed replace command more readable if you use different separator than /?
For example sed 's;a/a/a;b/b/b;g' looks better than sed 's/a\/a\/a\//b\/b\/b\//g'. :wink:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.