Re: how do I use super-sed's /S option?
"'Ruud H.G. van Tol' [email protected] [sed-users]" <[email protected]> Sat, 14 Jan 2017 18:35:16 +0100
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <[email protected]> |
On 2017-01-14 17:58, [email protected] [sed-users] wrote: > I'm trying to use super-sed's perl regex /S flag, but can't get it to work at all. This would be a very handy tool, if only I could understand how it's used! For example, I expect the following command will match and replace the pattern which spans across a newline to be replaced with Xs: > echo "(123) 456-7890\n(456) 567-9050" | sed -R -e "s/78.*?5/x/S" So, I am expecting this output: > (123) 456-78XX XXXXXXX67-9050 Instead I get (no match): > (123) 456-7890 (212) 567-9050 Maybe you meant "echo -e"? Without -e (the "\n" just means "n", and) it could work out like this: $ echo "(123) 456-7890\n(456) 567-9050" |sed -e "s/78[^5]*5/x/" (123) 456-x6) 567-9050 Your example output looks quite different. http://www.perlmonks.org/?node=XY+Problem What are you trying to achieve? -- Ruud Perl example that does a bit more: $ echo -e "(123) 456-7890\n(456) 567-9050" | perl -0pe 's/(78)(.*?)5/$1.("x"x length $2)/egs' (123) 456-78xxxxx6) 567-9050