Discussion:
how do I use super-sed's /S option?
raven_over_snow@yahoo.com [sed-users]
2017-01-14 16:58:46 UTC
Permalink
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








[Non-text portions of this message have been removed]
'Ruud H.G. van Tol' rvtol@isolution.nl [sed-users]
2017-01-14 17:35:16 UTC
Permalink
Post by ***@yahoo.com [sed-users]
(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
'Ruud H.G. van Tol' rvtol@isolution.nl [sed-users]
2017-01-14 17:44:11 UTC
Permalink
Post by ***@yahoo.com [sed-users]
(123) 456-7890 (212) 567-9050
See also:

http://stackoverflow.com/questions/41647885/how-do-i-use-super-seds-perl-regex-dot-match

-- Ruud

Loading...