EDIT: Nvm, figured out issue. Apparently it is unwise to modify the array in-place and leave it modified. Probably should be addressed, otherwise allows the utterly silly solution I just posted.
Agreed, the C# random testcases definitely seem to be broken. Seems to mostly happen when there are multiple words beginning and ending with the same letter.
If it's a very simple parse, like this, you'll get better performance and code that's easier to read by just writing it out imperatively. If it's a complicated parse, you'll be less likely to run into bugs, and have code that's easier to read, by using a proper parser DSL such as ANTLR. Regex isn't particularly good at either case, and its complexlity is extremely high. The "now you have two problems" joke exists for a reason.
Agree, this problem is hopelessly out of whack for C#. The rules are applied so inconsistently it is nearly impossible to figure out the correct solution for every random case.
For example: (M.-z vghqG&3kG]ptVQ;xZ/l:\oTjc&P'A*dN0iBU|Qnjw9>1k(]eP.p}?B'3{-@S+J=wBcj/cy)>!ACPB|ZGiU37d.NG;A DN7kl 7ICpVj2g^=
This one has multiple pipes so should fail, but doesn't, I guess because there is a random parenthetical in the middle?? It makes no sense how this is being parsed successfully when other similar ones fail.
EDIT: Nvm, figured out issue. Apparently it is unwise to modify the array in-place and leave it modified. Probably should be addressed, otherwise allows the utterly silly solution I just posted.
Agreed, the C# random testcases definitely seem to be broken. Seems to mostly happen when there are multiple words beginning and ending with the same letter.
Clever!
Really great code ; Learnt from it.
Regex is overkill for anything.
If it's a very simple parse, like this, you'll get better performance and code that's easier to read by just writing it out imperatively. If it's a complicated parse, you'll be less likely to run into bugs, and have code that's easier to read, by using a proper parser DSL such as ANTLR. Regex isn't particularly good at either case, and its complexlity is extremely high. The "now you have two problems" joke exists for a reason.
Trim replaces the spaces only in the beginning or end of a string. It combines "TrimStart" and "TrimEnd".
I thought Trim erase all spaces!, Does this only trim the two sides?
Sweet !
Is regex an overkill for this one? Just asking because I'm not really familiar with regex.
What a nice code...!
i was wondering about using a LINQ ; but yeah Regex does the work
Agree, this problem is hopelessly out of whack for C#. The rules are applied so inconsistently it is nearly impossible to figure out the correct solution for every random case.
For example:
(M.-z vghqG&3kG]ptVQ;xZ/l:\oTjc&P'A*dN0iBU|Qnjw9>1k(]eP.p}?B'3{-@S+J=wBcj/cy)>!ACPB|ZGiU37d.NG;A DN7kl 7ICpVj2g^=
This one has multiple pipes so should fail, but doesn't, I guess because there is a random parenthetical in the middle?? It makes no sense how this is being parsed successfully when other similar ones fail.
I like it. Very nifty!
Wouldn't do such a thing at work though. 9/10 colleques won't understand what's happening.
Cheater :P
Great code! It just inspired me!
Loading more items...