XXXX redacted: Difference between revisions
Content added Content deleted
(Added FreeBASIC) |
(Add ed example) |
||
Line 778: | Line 778: | ||
[p|i|o] XXX? XXXX XXXXXX XXXXXX is in his XXXXXXX while playing the "XXXXXXX" brand XXXXXXXX. That's so XXX</pre> |
[p|i|o] XXX? XXXX XXXXXX XXXXXX is in his XXXXXXX while playing the "XXXXXXX" brand XXXXXXXX. That's so XXX</pre> |
||
=={{header|ed}}== |
|||
Uses non-portable [[GNU Ed]] extension for case-insensitive matching. The number of replacement lines has to be copy-pasted as many times as necessary for full replacement. Because, unlike [[sed]], ed has no loops. Also note that the replacement is always three X-es, because ed has no way to customize the replacement length. |
|||
<syntaxhighlight lang="sed"> |
|||
H |
|||
2,j |
|||
1s/.*/&|/ |
|||
,j |
|||
t |
|||
t0 |
|||
t0 |
|||
t0 |
|||
t0 |
|||
t0 |
|||
# Repeat as many times as possible. Because ed has no loops |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)\b\1\b/\1|\2XXX/g |
|||
1s/^(.*)\|(.*)$/\2/ |
|||
2s/^(.*)\|(.*)\b\1\b/\1|\2XXX/gi |
|||
2s/^(.*)\|(.*)\b\1\b/\1|\2XXX/gi |
|||
2s/^(.*)\|(.*)\b\1\b/\1|\2XXX/gi |
|||
2s/^(.*)\|(.*)\b\1\b/\1|\2XXX/gi |
|||
2s/^(.*)\|(.*)\b\1\b/\1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ty descriptions |
|||
1s/.*/Whole word: &/ |
|||
2s/.*/Whole word, case insensitive: &/ |
|||
3s/.*/Partial word: &/ |
|||
4s/.*/Partial word, case insensitive: &/ |
|||
5s/.*/Partial word, overkill: &/ |
|||
6s/.*/Partial word, case insensitive, overkill: &/ |
|||
,p |
|||
Q</syntaxhighlight> |
|||
{{out}} |
|||
<pre>$ cat xxx-redacted.ed | ed -lEGs xxx-redacted.input |
|||
Whole word: XXX? Toms bottom tomato is in his stomach while playing the "XXX-tom" brand tom-toms. That's so tom. |
|||
Whole word, case insensitive: XXX? Toms bottom tomato is in his stomach while playing the "XXX-XXX" brand XXX-toms. That's so XXX. |
|||
Partial word: XXX? XXXs bottom tomato is in his stomach while playing the "XXX-tom" brand tom-toms. That's so tom. |
|||
Partial word, case insensitive: XXX? XXXs botXXX XXXato is in his sXXXach while playing the "XXX-XXX" brand XXX-XXXs. That's so XXX. |
|||
Partial word, overkill: XXX? XXX bottom tomato is in his stomach while playing the "XXX-tom" brand tom-toms. That's so tom. |
|||
Partial word, case insensitive, overkill: XXX? XXX XXX XXX is in his XXX while playing the "XXX-XXX" brand XXX-XXX. That's so XXX.</pre> |
|||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |