use strict;
my $str = 'Как защитить чат от длинных символов 123?
Всем здравствуйте, я хотел бы попросить у вас помощи. Дело в том, что существует так называемые символы, которые "ломают чат". Их длина очень большая и занимает пол чата, а то и весь. Мне очень нужно узнать, как защитить чат от этих символов. Вот пример символов: ̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿|̳̳̳̳̿̿̿̿l̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿|̳̳̳̳̿̿̿̿l̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊̿̿̿̿̊ é̴̢̢̢̧̡̧̡̢̡̧̡̡̡̨̛̛̛̥̟̹͖̲̙̪̙̠̙͍̹̦̦͇̣̯͓̯͈͔̺̺̯͚̱͔̻̖̰̖̙̟͇̘͍͉̱̟͓̞͓̘͓̟̳͕̲̞̫̱̖̗̘͇̯͎̝̹̥̲͍̥͉̳̠̥͕̗͔̟͖͇͖͓̭͖̜̱̠̳̺͚̖̿͒̾̑̌̆̀̎͋̀̈́̓̓̄̂́̃̀̈́̋̎̎͌̈́̓̃̈́̐̾̀̃̎́̈͛̽̔͊͐́͌̿̐̍̈̔̒̽̿͐̅́́̊̿̉̑̑͒̔́̓̄͊̀̋̓͛̇̍̇̈́͐͑̇̌̓̓͂̎̅͘̚̚̕͘̕̚͜͝͝͠͠͝͠͠͠ͅ.̨̡̢̢̧̧̨̨̧̢̧̛͙̟̮̩̥̻̬̱̝͔̝̼̗͖͎̪̲͓͔̝̤͖̫̳̟̪͎̳̭̞̝̣̗̝̱̱̮̠̙̟̙͖̤͔͇̩͍͙̰̭̝̫̜̺̝͓̻̱̤̲͉͙̦͕̰̣̬̣̺̖̘̘̮͈̭̫͍̻̰͍̼̤̙̩͖͇̒̌͆̔̄̔̓̏͛̉͛̈́̑̑̎̈́̑͂̾͑͆̑͂͂́̋͂̄̂̒̃̆̓̐̉̀̾̽͒̎̓͐͆͑̊̉͋͋̀̈́̓̎͛̌͌̂̽̔͆̍̊̓̽̂̆̀̿̀̋̍̃̔̉̇̎̋̈́͆̈́̚͘̚̕̚͘̕͘̚̚͘̚͝͝͠͠͝͝͝ͅͅͅ.̛̛̛̾͌͆̎̎̈̎͛͗͐̄̽̊̃̿͋͌͒̔͛̍̋̀̾̀̀̏̉͒̋́͑́͌͊̇̏̌̃̂̓̀͂̇̾͑̇̍̿̈́͂̽̈́͆͂̂̍́̂̂̾̔̍͋̓̕̚̚̕̕̕̕͝͠͠͝͝͝ Ỏ͖͈̞̩͎̻̫̫̜͉̠̫͕̭̭̫̫̹̗̹͈̼̠̖͍͚̥͈̮̼͕̠̤̯̻̥̬̗̼̳̤̳̬̪̹͚̞̼̠͕̼̠̦͚̫͔̯̹͉͉̘͎͕̼̣̝͙̱̟̹̩̟̳̦̭͉̮̖̭̣̣̞̙̗̜̺̭̻̥͚͙̝̦̲̱͉͖͉̰̦͎̫̣̼͎͍̠̮͓̹̹͉̤̰̗̙͕͇͔̱͕̭͈̳̗̭͔̘̖̺̮̜̠͖̘͓̳͕̟̠̱̫̤͓͔̘̰̲͙͍͇̙͎̣̼̗̖͙̯͉̠̟͈͍͕̪͓̝̩̦̖̹̼̠̘̮͚̟͉̺̜͍͓̯̳̱̻͕̣̳͉̻̭̭̱͍̪̩̭̺͕̺̼̥̪͖̦̟͎̻Ỏ͖͈̞̩͎̻̫̫̜͉̠̫͕̭̭̫̫̹̗̹͈̼̠̖͍͚̥͈̮̼͕̠̤̯̻̥̬̗̼̳̤̳̬̪̹͚̞̼̠͕̼̠̦͚̫͔̯̹͉͉̘͎͕̼̣̝͙̱̟̹̩̟̳̦̭͉̮̖̭̣̣̞̙̗̜̺̭̻̥͚͙̝̦̲̱͉͖͉̰̦͎̫̣̼͎͍̠̮͓̹̹͉̤̰̗̙͕͇͔̱͕̭͈̳̗̭͔̘̖̺̮̜̠͖̘͓̳͕̟̠̱̫̤͓͔̘̰̲͙͍͇̙͎̣̼̗̖͙̯͉̠̟͈͍͕̪͓̝̩̦̖̹̼̠̘̮͚̟͉̺̜͍͓̯̳̱̻͕̣̳͉̻̭̭̱͍̪̩̭̺͕̺̼̥̪͖̦̟͎̻Ỏ͖͈̞̩͎̻̫̫̜͉̠̫͕̭̭̫̫̹̗̹͈̼̠̖͍͚̥͈̮̼͕̠̤̯̻̥̬̗̼̳̤̳̬̪̹͚̞̼';
my $regex = qr/[^\p{Cyrillic}\p{Latin}\p{Common}\w\s]+/muip;
my $subst = '';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html