in reply to regex renaming

One way to replace is to use s///:
use strict; use warnings; my $text; while ( my $text = <DATA> ) { # match a word that contain 'ou' or # if ( $text =~ m/(ou)|(#)$/ ) { $text =~ s{[/\\]}{-}g; print $text; } } __DATA__ hello.world# world\tour Game.started

That replaces the \ and the / with -. You can add the rest.

UPDATE: added alternate delimiters in response to OP private msg.