Symbol Search Deleter [rephrased]

-1

Your challenge is to parse nonsensical text and output a "congruous phrase" - which I shall define here to be text with any contiguous characters in between, and including, a given set of like symbols removed.

The given set of like symbols (ignore all brackets and commas here, they're only for notation) are: {(< >), (^ ^), (' '), (: :), (% %)}


[NOTE: This question has been heavily refined after several critical errors were identified.]

EXAMPLE 1:

Thi'inquit Caecilius's qu % est provocationem %h^ ad howe et^s [ben] heavilede ^citi:ssim:e^< rn^> ^quolibe doetiguis^dited %inger 'ingenia'%! S__o:esse: rr %^umd^%y...

OUTPUT 1:

This qu hs [ben] heavilede dited ! S__o rr y

.

Be wary of the nested like symbol parts - e.g ^citi:ssim:e^ and < rn^> from above, where the pair : : are sandwiched between another pair ^ ^, and a half-pair ^ in between < >. Both of these non-congruous phrases must be removed.

EXAMPLE 2:

W%cd'fuf'dc%at<>ch^'o'^out!

OUTPUT 2:

Watchout!

.

EXAMPLE 3: Special Case (partial nested like symbols)

aaa^bbb%ccc'ddd^eee%ddd'fff

OUTPUT3: The first occurence of the given like symbol is the dominant; in this case ^

aaaeee%ddd'fff


The code must apply to the general case, so any text of your choosing, of length >= 30 characters, may be used as test cases.

The shortest code, in bytes, that completes this challenge successfully, is the winning code.

john321

Posted 2019-11-10T03:50:15.410

Reputation: 21

Question was closed 2019-11-10T06:36:00.377

3Scoring on character count is a bad idea. It leads to code that's gibberish packed into multibyte characters that's decompressed and run within the program. – xnor – 2019-11-10T07:18:52.857

@JoKing I'm terribly sorry, this gibberish has been corrected; different timezone here, so I wasn't quite myself.. – john321 – 2019-11-10T10:15:38.433

@xnor Thanks for pointing that out; it has been corrected to shortest bytes – john321 – 2019-11-10T10:16:06.290

Are you meant to take those symbols as input, or are they hardcoded? – Jo King – 2019-11-10T10:23:44.237

@JoKing They're hardcoded – john321 – 2019-11-10T10:26:38.433

You say the code must apply to the general case, so what do you expect for partially overlapping like symbol pairs like aaa^bbb<ccc^ddd>eee, or like symbol triples like aaa:bbb:ccc:ddd, or more complicated cases? – Anders Kaseorg – 2019-11-10T18:31:07.830

You need more test cases, clarifying "Be wary of the nested like symbol parts - e.g ^citi:ssim:e^ and < rn^>" – HiddenBabel – 2019-11-10T18:59:30.893

@AndersKaseorg Nice observation; in such special cases, the first like symbol to appear is the dominant one; see EXAMPLE 3 edit – john321 – 2019-11-10T19:39:35.457

@HiddenBabel Yes, I have added 2 more e.gs, involving separate special cases – john321 – 2019-11-10T19:40:30.587

1I'm voting to reopen this, but I don't think it is that interesting of a question – Jo King – 2019-11-10T23:57:36.827

1Could this be moved to the sandbox (where it probably should have started)? – ouflak – 2019-11-11T08:30:15.910

Answers

2

C# .NET, 162 bytes

using System;class A{static void Main(string[] s){Console.Write(System.Text.RegularExpressions.Regex.Replace(s[0],String.Format("([{0}]{{1}}).*?\\1",s[1]),""));}}

Try it online!

Er, the OP's test case is faulty. Either you remove all text between any two symbols, or you remove all text only between like symbols. OP does both in his test case... So I'm doing only between like symbols.

Takes as input the string to search and the character set to use. OP is incorrect about the output, though. It reads,

, Howarm y congruum dor ingqussld...

HiddenBabel

Posted 2019-11-10T03:50:15.410

Reputation: 603

Yes, I had meant like symbols, as you managed to somehow figure out from my gibberish; I have updated the question, and the difficulty has slightly increased due to nested like symbols. – john321 – 2019-11-10T10:18:16.147