Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request (sed): Support for extended match strings #1070

Open
brc-dd opened this issue Jan 24, 2022 · 4 comments
Open

Feature Request (sed): Support for extended match strings #1070

brc-dd opened this issue Jan 24, 2022 · 4 comments
Labels
bash compat Compatibility issues with bash or POSIX behavior feature low priority

Comments

@brc-dd
Copy link

brc-dd commented Jan 24, 2022

I would like to request support for expressions like this:

sed -i ':a;N;$!ba;s/\n/ /g' file

Refer: https://stackoverflow.com/a/1252191/11613622

Currently, it is only supported by GNU sed; can be considered as low-priority (though the linked SO thread has over 2M views).

@nfischer nfischer added feature low priority bash compat Compatibility issues with bash or POSIX behavior labels Jan 24, 2022
@nfischer
Copy link
Member

Is any of this supported by JavaScript regex?

@brc-dd
Copy link
Author

brc-dd commented Jan 24, 2022

@nfischer The branching and flow control part (:a;N;$!ba;) is not there in JS regex. The substitution (s/\n/ /g) can be directly done using JS replace.

Here are the official docs BTW: https://www.gnu.org/software/sed/manual/html_node/Multiline-techniques.html, https://www.gnu.org/software/sed/manual/html_node/Branching-and-flow-control.html

@nfischer
Copy link
Member

Hmm OK. Anything beyond simple regex support is unlikely to be supported. If you can refactor to use other unix commands instead (ex. see my replies on #983), I recommend using that workaround.

@brc-dd
Copy link
Author

brc-dd commented Jan 26, 2022

@nfischer Thanks. Well, I'm simply using replace with \n as match string for this particular case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bash compat Compatibility issues with bash or POSIX behavior feature low priority
Projects
None yet
Development

No branches or pull requests

2 participants