Jump to content

XXXX redacted: Difference between revisions

Removed flawed solution
(Removed flawed solution)
Line 978:
[p│s│o] Tom? Toms XXXXXX XXXXXX is in his XXXXXXX while playing XXX "XXXXXXX" brand XXXXXXXX. XXXXXX so XXX.
[p│i│o] XXX? XXXX XXXXXX XXXXXX is in his XXXXXXX while playing XXX "XXXXXXX" brand XXXXXXXX. XXXXXX so XXX.
</pre>
 
=={{header|Tailspin}}==
Tailspin currently does not recognize grapheme clusters in character iteration, so the last example gets an X for each code point.
 
The API design here is questionable but shows the alternatives of passing the flags inline in the string and passing the secret as a named parameter. A better design would probably do both the same way.
<lang tailspin>
composer redact&{secret:}
@: { fill: '', bounds: '', case: '' };
(<flags> <WS>*) [ <redact|keep>* ] -> '$...;'
 
rule flags: <='['> <word|partial> <='|'> <insensitive|sensitive> <='|'> <overkill|normal> <=']'>
rule word: (<='w'> -> ..|@:{bounds: '\b{g}'};)
rule partial: <='p'>
rule insensitive: (<='i'> -> ..|@:{case: '(?i)'};)
rule sensitive: <='s'>
rule overkill: (<='o'> -> ..|@:{bounds: '\b{g}', fill: '\w*'};)
rule normal: <='n'>
rule redact: <'(?uU)$@.case;$@.bounds;$@.fill;$secret;$@.fill;$@.bounds;'> -> [$... -> 'X'] -> '$...;'
rule keep: <~redact>
end redact
 
def target: 'Tom? Toms bottom tomato is in his stomach while playing the "Tom-tom" brand tom-toms. That''s so tom.';
def options: ['[w|s|n]', '[w|i|n]', '[p|s|n]', '[p|i|n]', '[p|s|o]', '[p|i|o]'];
 
'Redacting Tom:
' -> !OUT::write
$options... -> \('$;: ' -> !OUT::write '$; $target;' -> redact&{secret: 'Tom'} -> '$;
' -> !OUT::write \) -> !VOID
 
'
Redacting tom:
' -> !OUT::write
$options... -> \('$;: ' -> !OUT::write '$; $target;' -> redact&{secret: 'tom'} -> '$;
' -> !OUT::write \) -> !VOID
 
'🧑 👨 🧔 👨‍👩‍👦' -> '[w|s|n] $;' -> redact&{secret: '👨'} -> '
$;
' -> !OUT::write
 
'🧑 👨 🧔 👨‍👩‍👦' -> '[w|s|n] $;' -> redact&{secret: '👨‍👩‍👦'} -> '
$;
' -> !OUT::write
</lang>
{{out}}
<pre>
Redacting Tom:
[w|s|n]: XXX? XXXs bottom tomato is in his stomach while playing the "XXX-tom" brand tom-toms. That's so tom.
[w|i|n]: XXX? XXXs botXXX XXXato is in his sXXXach while playing the "XXX-XXX" brand XXX-XXXs. That's so XXX.
[p|s|n]: XXX? XXXs bottom tomato is in his stomach while playing the "XXX-tom" brand tom-toms. That's so tom.
[p|i|n]: XXX? XXXs botXXX XXXato is in his sXXXach while playing the "XXX-XXX" brand XXX-XXXs. That's so XXX.
[p|s|o]: XXX? XXXX bottom tomato is in his stomach while playing the "XXX-tom" brand tom-toms. That's so tom.
[p|i|o]: XXX? XXXX XXXXXX XXXXXX is in his XXXXXXX while playing the "XXX-XXX" brand XXX-XXXX. That's so XXX.
 
Redacting tom:
[w|s|n]: Tom? Toms botXXX XXXato is in his sXXXach while playing the "Tom-XXX" brand XXX-XXXs. That's so XXX.
[w|i|n]: XXX? XXXs botXXX XXXato is in his sXXXach while playing the "XXX-XXX" brand XXX-XXXs. That's so XXX.
[p|s|n]: Tom? Toms botXXX XXXato is in his sXXXach while playing the "Tom-XXX" brand XXX-XXXs. That's so XXX.
[p|i|n]: XXX? XXXs botXXX XXXato is in his sXXXach while playing the "XXX-XXX" brand XXX-XXXs. That's so XXX.
[p|s|o]: Tom? Toms XXXXXX XXXXXX is in his XXXXXXX while playing the "Tom-XXX" brand XXX-XXXX. That's so XXX.
[p|i|o]: XXX? XXXX XXXXXX XXXXXX is in his XXXXXXX while playing the "XXX-XXX" brand XXX-XXXX. That's so XXX.
 
🧑 X 🧔 👨‍👩‍👦
 
🧑 👨 🧔 XXXXX
</pre>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.