in reply to Re: Reg exp questions
in thread Reg exp questions

and if I have one space before the end of the $str and one (, one ), this doesn't work with or without / for ()

$str =~ s/()[\s]/_/;

Replies are listed 'Best First'.
Re^3: Reg exp questions
by toolic (Bishop) on Nov 07, 2014 at 19:31 UTC
    Show your exact input strings, and your expected output strings. http://sscce.org

      my $str = 'dfsldjf(djfls)jfslfk kfds\nfjsldf';

      output: dfsldjf_djfls_jfslfk_kfds fjsldf

        Did you really mean to include a newline character (single quotes prevent interpolation)?
        use warnings; use strict; my $str = 'dfsldjf(djfls)jfslfk kfds\nfjsldf'; $str =~ s/[\s()]/_/g; $str =~ s/\\n/ /g; print "$str\n"; __END__ dfsldjf_djfls_jfslfk_kfds fjsldf